

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
C++ warm-up exercises covering various topics such as input and output, boolean expressions, and variables. The exercises include understanding the effect of specific statements, reading data from a file, and evaluating boolean expressions. Students will practice interpreting code and identifying the expected output.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Chapter 4 warm up exercises If input data are 10 20 30 40 50 60 10 20 30 40 50 60 10 20 30 40 50 60 70 80 and the input statements are: cin >> a >> b >> c; cin.ignore(100, ‘\n’); cin.get(ch1); cin >>d >>e >>f; cin.ignore(100, ‘\n’); cin.ignore(100, ‘\n’); cin >> a >> b; what is produced by cout << a <<” “ <<b <<endl; cout << c <<” “ <<d <<” “<<e<<endl; cout <<f<<endl; What is the effect of the following statements? String coco; isfstream inFile; infile.open(“datafile.dat”); getline(infile, coco); Suppose a file named bobo.data contains only a collection of whole numbers. Write the statements necessary to read all the data from the file and output the number of items in the file.
Chapter 5 warm up exercises Suppose int1 has the value 12, int2 has the value 18, and int3 has the value 21. What is the result of each of the following boolean expressions? a. int1 < int2 && int2 < int b. int1 > int2 && int2 < int c. int1 > int2 || int2<int d. int1 <= int2 – 6 e. int1++ <= int2 - f. int2 <= int1 + 5 || int3 >= int2 + 5 g. !( int1 < 30 ) h. !(int2 == int1 && int3 > int1) i. !(int1 > 25) && (int1 < 17) Suppose x is of type int, what values of x make the following evaluate to true? ! ((x < 12) || (x >23)) !( x > 5 && x <7 ) What is the value of each of the following? ‘A’ < ‘B’ ‘a’ < ‘b’ ‘a’ < ’B’ Suppose a, b, and x are of type int Which of the following expressions is preferable? a = b/x && x != 0 x != 0 && a = b/x x != 0 || a = b/x