Test 1 CSCI 130
Summer 2013
- Please answer each question fully, carefully and thoughtfully.
- No credit will be given for unreadable answers, please write neatly.
- Answer the questions in any order, but please number each answer.
- Make sure that your name is on your test.
- Algorithms
- [2 points] What is an algorithm? Give the definition.
- [4 points] How is an algorithm employed in the development process?
- Programming Tools
- [2 points] What is a text editor?
- [2 points] Name the primary task of a compiler.
- [2 points] What is a secondary task of a compiler?
- Identifiers
- [2 points] What is an identifier?
- [6 points] Give the syntax rules for constructing an identifier and an example which violates each rule. State how your example violates the rule.
- Constants and Variables
- [2 points] Give the syntax for declaring a named constant.
- [1 point] Give example code which declares a string constant.
- [2 points] Give the syntax for declaring a variable.
- [1 point] Give example code which declares an integer variable.
- [2 points] How is a variable different from a constant?
- [2 points] What are the conventions for a variable name?
- Data Types
- [2 points] What is a data type?
- [2 points] Describe the string data type.
- [2 points] What is the difference between a character and a string?
- [4 points] Justify why it is better to use the constant
SALES_TAX
than the floating point literal 0.06 in a program.
- [10 points] Write a complete C++ program which will prompt the user for two positive integers a and b and print a/b as a mixed number. If the numbers are
4
and 3
, the output would be 4/3 = 1 and 1/3
, while the input 6
and 2
will output 6/2 = 3 and 0/2
. You may assume that b will not be 0.