Adama Science and Technology University School of Engineering Department of Information Technology

Adama Science and Technology University School of Engineering Department of Information Technology

Comp 234 Mid Exam

Time allowed: 1:00 hour

Name: _____________________________ ID : ____________

General instructions:  Do not start until instructed to do so!

Make sure that the exam paper contains 10 questions

Do not forget to write your name and ID

Make your handwriting legible For instructor’s use only 30 %

1. Define : ( 1 pt each) a. Variable b. Data type 2. Which of the following represent valid identifiers (variable)?(0.5 point each) Identifier Valid seven_11 _unique_ gross-income gross$income 2by2 Default average_weight_of_a_large_pizza Variable

3. Describe steps of creating a C++ program ( compilation process)( 2 pts)

4. All programs can be written in terms of three types of control structures: ____________, ____________and____________.

5. The__________ selection statement is used to execute one action when a condition is TRue or a different action when that condition is false.

6. Identify and correct the errors in each of the following on the space provided ( 1 pt each) a. while ( c <= 5 ) { product *= c; c++; b. cin << value; c. if ( gender == 1 ) cout << “Woman” << endl; else; d. cout << “Man” << endl;

7. What, if anything, prints when each of the following C++ statements is performed? If nothing prints, then answer “nothing.” Assume x = 2 and y = 3.( 1 pt each) a. cout << x; ____________ b. cout << x + x;__________ c. cout << “x=”;___________ d. cout << “x = ” << x;________ e. cout << x + y << ” = ” << y + x;_________ f. cin >> x >> y;__________ g. // cout << “x + y = ” << x + y; ___________ h. cout << “\n”;__________________

8. Determine the output of the following fragment of code as if it is embedded in a working c++ program (4pts). a. Output { int min, i = 10, j = 20; min = (i < j ? i : j); cout << min << ‘\n’; } b. int x = 7; Output int y = 5; cout<<“x =” << x<<“, y= “<

Leave a Reply

Your email address will not be published. Required fields are marked *