WorksheetsCPR _Chapter2 _Onlinequiz
Total questions: 15
Worksheet time: 22mins
What will be the output of following program ?
#include <stdio.h>
void main()
{
int i=1;
do
{
printf("%d,",i);
i=i+1;
}while(i>=10);
printf("\nAfter loop i=%d",i);
printf("\n");
}
After loop i=1
1
After loop i=2
After loop i=2
None of the above
Choose a right C Statement.
Loops or Repetition block executes a group of statements repeatedly.
Loop is usually executed as long as a condition is met.
Loops usually take advantage of Loop Counter
All the above.
What is the output of C Program.?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
What is the output of C Program.?
int main()
{
int k;
for(k=1; k <= 5; k++);
{
printf("%d ", k);
}
return 0;
}
1 2 3 4 5
1 2 3 4
5
6
What is the way to suddenly come out of or Quit any Loop in C Language.?
continue; statement
break; statement
leave; statement
quit; statement
Choose a correct C for loop syntax.
for(initialization; condition; increment operation)
{
//statements
}
for(declaration; condition; increment operation)
{
//statements
}
for(declaration; increment operation; condition)
{
//statements
}
for(initialization; condition; increment operation;)
{
//statements
}
What is the output of C Program with switch statement.?
int main()
{
int a=3;
switch(a)
{
case 2: printf("ZERO "); break;
case default: printf("RABBIT ");
}
}
RABBIT
ZERO RABBIT
No output
Compiler error
What is the output of C Program with switch statement or block.?
int main()
{
static int a=5;
switch(a)
{
case 0: printf("ZERO ");break;
case 5: printf("FIVE ");break;
case 10: printf("DEER ");
}
printf("LION");
}
ZERO FIVE DEER LION
FIVE DEER LION
FIVE LION
Compiler error
#include <stdio.h>
void main()
{
int x = 0;
if (x == 0)
printf("hi");
else
printf("how are u");
printf("hello");
}
hi
how are u
hello
hihello
What is the output of C Program.?
int main()
{
int a=9;
if(a==9);
{
printf("Ostrich\n");
}
elseif(a==8)
{
printf("Eggs\n");
}
else
printf("White");
return 0;
}
White
Ostrich
White
compiler error
How many choices are possible when using a single if-else statement?
1
2
3
4
A "switch" statement is used to
Switch between functions in a program
witch from one variable to another variable
To choose from multiple possibilities which may arise due to different values of a single variable
.All of above
Loops in C Language are implemented using.?
While
For
Do While
All the above
Choose a correct syntax of if -else Conditional Statement.
if( condition )
{
//statements;
}
if( condition )
{
//statements;
}
else
{
//statements;
}
if( condition1 )
{
//statements;
}
else if( condition2)
{
//statements;
}
else
{
//statements;
}
All the above.
Which loop is most suitable to first perform the operation and then test the condition?
for loop
while loop
do-while loop
none of the mentioned
