



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




What is the correct way to write the condition y < x < z? - ANSWER ((y< x ) && ( x < z ))
Every line in a program should have a comment. (T/F) - ANSWER False
Given the following code fragment and the input value of 2.0, what is the output generated?
float tax; float total;
cout << "enter the cost of the item\n"; cin >> total; if ( total >= 3.0) { tax = 0.10; cout << total + (total * tax) << endl; } else { cout << total << endl; } - ANSWER 2.
Variable names may begin with a number. (T/F) - ANSWER False
Given the following code fragment, which of the following expressions is always TRUE?
int x; cin >> x; - ANSWER if ( x = 1)
What is the value of x after the following statement?
float x; x = 3.0 / 4..0 + (3+2) /5 - ANSWER 1.
What is the value of x after the following statements?
int x; x = 15 % 4; - ANSWER 3 (not 3.75 bc x is int and not a double or float)
The opposite of less than is greater than - ANSWER False
The opposite of (x >3 && x < 10) is (x < 3 && x >10) - ANSWER False
The body of a do while loop always executes at least once. - ANSWER True
Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x < 3)
The body of a while loop may never execute. - ANSWER True
The integer 0 is considered true - ANSWER True
Given the following code fragment, what is the output? int x=5; if(x >5) cout << "x is bigger than 5"; cout << "That is all"; cout << "Goodbye"; - ANSWER That is all. Goodbye
loops are used when we need out program to make a choicer between two or more things. - ANSWER False
Given the following code fragment, and an input value of 5, what is the output?
int x; if( x< 3) { cout << "small\n";} else { if( x < 4) { cout << "medium\n"; } else { if( x < 6) { cout << "large\n"; } else { cout << "giant\n"; } }} - ANSWER Large
in the Following code fragment, x has the value of 3.
int x = 3; - ANSWER True
is is legal to declare more than one variable in a single statement. - ANSWER True.