# Decision Making and Looping

This Test will cover the Decision Making and Looping of C Langauge, including if-else statement, switch statement, for loop, while loop etc.
Q. What will be the result of given code?
``````main()
{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}``````
 A. zero B. three C. error D. none of the above
Q. What will be the result of given code?
``````main()
{
int i = 1;
for(;;)
{
printf("%d",i++);
if(i > 5)
break;
}
}``````
 A. 1 2 3 4 5 B. error because condition in for loop is must C. error because of two semicolon inside for loop. D. error because of break inside for loop.
Q. What will be the result of given code?
``````main()
{
int i = 1;
int j = 2;
switch(i)
{
case 1: printf("one");
break;
case j: printf("two");
break;
}
}``````
 A. one B. two C. error because constant expression require in place of j. D. none of the above.

Q. What will be the result of given code?
``````main()
{
printf(5 + "Good Morning");
}``````
 A. error B. Good Morning C. Morning D. Good
Q. Can we use string inside switch statement?
 A. Yes B. No
Q. What will be the result of given code?
``````main()
{
int a =10;
if(a = 5)
printf("hello");
else
printf("bye");
}``````
 A. hello B. hellobye C. bye D. error
In situations where we need to execute body of the loop before testing the condition, we should use __________.
 A. for loop B. while loop C. do while loop D. nested for loop

Q. What will be the result of given code?
``````main()
{
int i;
printf("%d", scanf("%d", &i));    // value 10 is given as input here
}``````
 A. error B. 1 C. 10 D. none of the above
Q. What will be the result of given code?
``````main()
{
switch (2)
{
case 1: printf("one");
case 2: printf("two");
case 3: printf("three");
default: printf("four");
}
}``````
 A. two B. two three C. two three four D. error
Q. What will be the result of given code?
``````main()
{
int a = 0;
if(a)
printf("Study");
else
printf("tonight");
}``````
 A. error B. study C. tonight D. none of the above

### Related Tests:

#### Explore more Subjects:

Tests for various other programming languages and subjects: