Questions and CORRECT Answers
What must every C program have? - CORRECT ANSWER- Main
Every statement in C must end with a... - CORRECT ANSWER- semicolon(;)
What is NOT a valid integer value? - CORRECT ANSWER- any decimal point because they
are FLOATS
What is an INVALID identifier (variable name)? - CORRECT ANSWER- ex: 5test (because
it begins with a number)
ex: _test (this works, but it is not recommended)
What is an iteration/loop statement? - CORRECT ANSWER- - do...while
- for
if and if...else are NOT looping statements!
How many times will the following program print hello?
i = 1;
while (i<=10)
{ printf("hello"); } - CORRECT ANSWER- An infinite amount of times -->
because there is no increment and the condition is always true
Consider the following correct segment of a correct C program:
, p=2;
while (p<1000)
{ p = 2*p; }
What is the value of p AFTER this while loop completes its execution? - CORRECT
ANSWER- 1024
because the numbers are always going to end in even digits, and anything higher than in the
thousands is incorrect because of the condition
An uninitialized variable contains _________________. - CORRECT ANSWER- the value
last stored in the memory location reserved for that variable
What is the FINAL value of x after performing the following operations?
int x = 21;
double y = 6;
double z = 14;
y = x/z;
x = 5.5*y; - CORRECT ANSWER- 8.25
(double = doubling the float)
when you're diving an integer by a float, the answer is a float.
Having a loop within a loop is known as... - CORRECT ANSWER- nesting
Which assignment expression is equivalent to c = c/2?
a. c / = 2
b. c / c = 2
c. c /= 2