C++ T/F questions

Questions : answer True (T) or False (F)
#1: An identifier can be any sequence of digits, letters, and the underscore
character.
#2: You can use the function getline to read a string containing blanks
(whitespaces).
#3: Suppose a = 10; After the execution of ++a, the value of a is 11.
#4: The expression !(x < 0) is true only if x is a positive number.
#5: After the execution of the following code, sum = 15?
sum = 0;
num = 10;
if (num > 0)
sum = sum + 10;
else if (num > 5)
sum = num + 15;#6: After the execution of the following code, is the output “4 7 10”?
#include<iostream>
using namespace std;
int main()
{
int x=4, y=4, z=4;
x += 2;
y = z++;
z = ++x + y;
cout<<x<<" "<<y<<" "<<z<<endl;
return 0;
}
#7: The value of the expression, 6 < 5 || 'g' > 'a' && 7 < 4 is false.
#8: The digit 0 or 1 is called a binary digit, or “bits”.
#9: In a selection control structure, the computer executes particular
statements depending on some condition(s).
#10: Suppose that alpha is a double variable. The value of alpha is “21.5”
after
the following statement executes:
alpha = 14.0 + static_cast<double>(15 / 2);
#11: Assume all variables are properly declared. The output of the following
C++ code is 0 1 2 3 4.
n = 1;
while (n < 5)
{
cout << n << " ";
n++;
}#12: Assume all variables are properly declared. The output of the following
C++ code is 1 2 3 4 5 6 7 8 9 10.
for (i = 1; i <= 10; i++)
cout << i << " " ;
#13: do-while loop is guaranteed to be execute at least once.
#14: <= means “less than or equal to”
#15: An infinite loop is a loop that continues to execute endlessly.
#16: Suppose x is 7 and y is 7. Choose the value of the following expression:
(x == 7) && (x <= y)
#17: Is the output of the following C++ code 10 8 6 4 2 ?
int alpha[5] = {2, 4, 6, 8, 10};
int j;
for (j = 4; j >= 1; j--)
cout << alpha[j] << " ";
cout << endl;
#18: Consider the following declaration int intArray[4] = {3, 4, 5, 6};. Is int
alpha[]={3,4,5,6} equivalent to this statement?
#19: A ‘ + ’ sign in front of a member name on the UML diagram indicates
that this member is a private.
#20: global variables can be accessed by the main method only.
What are your guesses and why do you think them?
Topic archived. No new replies allowed.