PDF Download
FREE AND STUDY GAMES ABOUT COMPUTER SCIENCE
E#2 EXAM QUESTIONS
Actual Qs and Ans Expert-Verified Explanation
This Exam contains:
-Guarantee passing score -60 Questions and Answers -format set of multiple-choice -Expert-Verified Explanation Question 1: When a loop is nested inside another loop, the outer loop goes through all its iterations for each iteration of the inner loop.
Answer:
False
Question 2: In C++, !, &&, and || are called relational operators.
Answer:
False Question 3: Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code?cin >> sum; cin >> num; for (j = 1; j <= 3; j++) { cin >> num; sum = sum + num;
} cout << sum << endl;
Answer:
24 Question 4: The ideal loop to use for validating a value entered at the keyboard is
Answer:
do-while Question 5: If the code below is executed and the user enters 10 20 30 40 -1, the output will be: int num, accu = 0; cin>>num; while(num != -1) { accu = accu + num; cin>>num; } cout< 100 Question 6: To use a predefined value-returning function in a program, the programmer only needs to know the appropriate header file, the name of the function, and the type of the value returned by the function. False int limit; int counter = 0; cin >> limit; while (counter < limit) { cin >> entry; triple = entry * 3; cout << triple; counter++; } cout << endl; This code is an example of a(n) ____ while loop. counter-controlled Question 8: Consider the following code. (Assume that all variables are properly declared.) cin >> ch; while (cin) { cout << ch; cin >> ch; } This code is an example of a(n) ____ while loop. EOF-controlled Question 9: To use the predefined function abs, the program must include the header file ctype. False for (incount = 1; incount <= 3; incount++ ) cout << incount << ' '; cout << endl; } What is the output after the statements above execute? 123 123 Question 11: If the code below is executed, the output will be: int x = 3; do { cout< int j; for (j = 10; j <= 10; j++) cout << j << " "; cout << j << endl; 10 11 Question 13: To use a predefined function, the program must include the appropriate header file. True All of the above Question 15: Relational and logical expressions allow to incorporate decision making into programs. TrueAnswer:
Answer:
Question 7: Consider the following code.
Answer:
Answer:
Answer:
Question 10: for (outcount = 1; outcount <= 2; outcount++ ) {
Answer:
Answer:
Question 12: What is the output of the following C++ code?
Answer:
Answer:
Question 14: The ++ operator
Answer:
Answer: