CS 7643 QUIZ 3 COMPREHENSIVE TEST
PAPER WITH SOLVED QUESTIONS
◉ 3.42 Consider the following correct segment of a correct C
program:
p = 2;
while (p < 2000) {
p = 2 * p;
}
What is the value of p after this while loop completes its
execution?
a) 1023
b) 1024
c) 2047
d) 2048
Answer: D
◉ 3.41 How many times will the following program print hello?
i = 1;
while (i <= 10) {
puts("hello");
}
, (a) 10
(b) 8
(c) an infinite number of times
(d) 0
Answer: C
◉ 3.40 What is wrong with the following loop?
While (sum <= 1000) {
sum = sum + 30;
}
(a) The parenthesis should be braces.
(b) The braces around sum = sum +30; should be removed.
(c) While should be while.
(d) There should be a semicolon after While (sum <=1000).
Answer: C
◉ 3.39 The empty statement is represented by placing __________
where a statement would normally be.
a) empty
b) ;
c) null
d) :
PAPER WITH SOLVED QUESTIONS
◉ 3.42 Consider the following correct segment of a correct C
program:
p = 2;
while (p < 2000) {
p = 2 * p;
}
What is the value of p after this while loop completes its
execution?
a) 1023
b) 1024
c) 2047
d) 2048
Answer: D
◉ 3.41 How many times will the following program print hello?
i = 1;
while (i <= 10) {
puts("hello");
}
, (a) 10
(b) 8
(c) an infinite number of times
(d) 0
Answer: C
◉ 3.40 What is wrong with the following loop?
While (sum <= 1000) {
sum = sum + 30;
}
(a) The parenthesis should be braces.
(b) The braces around sum = sum +30; should be removed.
(c) While should be while.
(d) There should be a semicolon after While (sum <=1000).
Answer: C
◉ 3.39 The empty statement is represented by placing __________
where a statement would normally be.
a) empty
b) ;
c) null
d) :