UNIT-2 : DECISION & LOOP CONTROL STATEMENTS
1.
Which of the following is not a loop structure?
(a) for (b) do-while (c) repeat-until (d) while
2.
If statement is a
—————statement
(a) One-way
decision (b) Multi-way decision (c)
Two way decision (d) Loop construct
3.
‗break‘ statement in a loop is used for
(a) Terminating the loop (b) De-allocating memory
(c) Terminating the program (d)
Terminating the function
4.
The keyword ―else‖ can be used
with
(a) for statement (b)
do.. while ( ) statement (c) if
statement (d) switch ( ) statement
5.
The two different ways to implement a multiway
selection in C are
(a) Simple if and if-else (b) if-else
and nested if-else
(c) else-if ladder
and switch (d) None
6.
The minimum number of time that a do-while loop executes
(a) 0 (b) 1 (c) infinitely (d) variable
7.
The while loop is terminated when the conditional
expression returns
(a)
1 (b) 2 (c) 3 (d) Zero
8.
C
provides as
a convenient alternative to the traditional if-else for two way selection.
(a) Conditional operator (b) Short hand assignment (c) Increment (d) None
9.
The statement used to send back any value to the
calling function is
(a)
break (b) continue (c)
exit (d) return
10.
The statement is used to skip the remaining part of the
statements in a loop and continue with next
iteration.
(a) break (b) goto (c) continue (d) exit
11.
should be avoided as part of
structured programming approach
(a) break (b) goto (c) continue (d) exit
12. The minimum number of times ―for‖ loop executes
(a) 2 (b) can‘t
be predicted (c) 0 (d) 1
13.
{ int fruit=1; switch(fruit+2)
{
default:printf("apple"); case
4: printf(" banana");
case 5: printf(" orange"); case
8: printf(" grape");
}
}
(a) applebanana orange grape (b) grape (c)
orange (d) banana orange grape
14.
Which for loop has range of similar
indexes of 'i' used in for (i = 0;i< n; i++)? (a) for (i = n; i>0;
i–) (b) for (i = n; i >=
0; i–)
(c) for (i = n-1; i>0;
i–) (d) for (i = n-1; i>-1; i–)
15.
What will be output when you will
execute following C code? void main()
{
int check=2; switch(check)
{
case 2:
printf("1");
break;
case 3: printf(" 2");
break;
}
}
(a) 12 (b)
2 (c) 1 (d) Compilation error
16.
Which one among the following is the correct syntax
of for loop?
(a) for(i=0;i<n;i++); (b) for(i<n;i=0;i++);
(c) for(i=0;i<n:i++); (d) None
17.
‗for‘ loop in C program , if the condition is missing
(a)
assumed to be present and taken to be false
(b) assumed to be present and taken to be true
(c)
syntax error
(d)
execution will be terminated abruptly
18.
if c is initialized to 1, how many times following
loop is executed While((c>0)&&(c<60))
{ c++; }
(a) 60 (b) 59 (c)
61 (d)1
19. The library function exit () causes an exit from
(a)
loop (b) block (c)function (d) None
20. break statement
can use with
i) loop ii)switch iii)
block
(a) onlyi,ii (b) only ii,iii (c) only i, iii (d) All
21.
What is the output of this C code? int
main()
{
while ()
printf("In while loop "); printf("After loop\n");
}
(a)
In while loop after loop (b) After loop (c) Compile time error(d) Infinite loop
22. Which among the
following is not checked in switch case
(a) character (b) integer (c) float (d) None
23.
What is the output of the following
program main()
{
int i;
for(i=1;i<5;i++)
{ if(i==3)
break;
Printf(―%d‖,i);
}
}
(a) 12345 (b)124 (c)1245 (d)12
24.
What is the output of the following
program main()
{ int
i;
for(i=1;i<5;i++)
{
if(i==3)
continue; Printf(―%d‖,i);
}
}
(a) 12345 (b)124 (c)1245 (d)12
25. What are the
entry controlled loops among the following
i. while ii. Do-while iii.
For
(a) only i (b) only ii,iii (c) only iii (d) only i, iii
26.
What is the output of the following
program? main()
{
int i=1;
while(i<=5)
printf(―%d‖,i);
}
(a)
12345 (b)1234 (c) 2345 (d) Leads to infinite loop
27.
for(;;) can be terminated by
(a)
break (b) exit(0) (c) return (d) All the above
28.
What is the output of the following
program main()
{
for(i=1;i<=5;i++);
printf(―%d‖,i);
}
(a) 12345 (b)1234 (c) 6 (d) leads to infinite loop
29. What is the
correct syntax of for loop
(a) for(i=0;i<n;i++){ } (b)
for(i<n;i=0;i++){ }
(c) for(i=0;i<n:i++){} (d) for(i=0:i<n:i++){ }
30. Array is an
example of which of the following?
(a) Derived types (b) Fundamental types (c)
User-defined types (d) None
31. Which of the
following is used to display a string on the
screen?
(a) %s (b) %c (c) %d (d) %f
32. What is the final
value of x when the code int x; for(x=0; x<10; x++) {} is run?
(a) 10 (b) 9 (c) 0 (d) 1
33. Which of the
following is exit controlled loop
(a) for (b) while (c) do-while (d) None
34. The default
statement is executed when
(a) All the case statements are false (b) One of the case is true
(c) One of the case is
false (d) None
35.
How many times the following C code prints ―Hello‖
int main()
{
while (1) printf("Hello ");
}
(a) One (b) zero (c) Infinite (d) Produce error
36.
How many times the following C code prints
―Hello‖ int main()
{
do
{
printf("Hello
");
}while(0);
}
(a) One (b) zero (c)
Infinite (d) Produce error
37.
How many bytes
the array price occupies. float price[10];
(a) 10 bytes (b) 4 bytes (c) 40 bytes (d)
20 bytes
38. Which of the
following is syntactically correct?
(a) for(); (b) for(;); (c) for(,); (d) for(;;);
39.
What is the output of the following
code main()
{
int a= 0,b = 20;
char x =1,y =10; if(a,b,x,y)
printf("hello");
}
(a) Syntax error (b) hello (c)
10 (d) None
40.
is used to terminate from the entire program
(a) return (b) break (c) exit (d)
goto
Related Posts
Subscribe Our Newsletter
0 Comments to "UNIT-2 : DECISION & LOOP CONTROL STATEMENTS"
Post a Comment
Share your view here!!