NEW
Font size
WorksheetsDay 5 condition & Loops
Total questions: 12
Worksheet time: 6mins
The continue statment cannot be used with
for
while
do while
switch
Which keyword can be used for coming out of recursion?
return
break
exit
both A and B
goto can be used to jump from main to within a function?
True
False
May be
Can't say
Which loop is guaranteed to execute at least one time.
for
while
do while
None of the above
What is the output of this program?
#include <stdio.h>
int main()
{
int i;
for (i = 0;i < 5; i++)
int a = i;
printf("%d", a);
}
Syntax error in declaration of 'a' variable
No errors, program will show the output 5
Redeclaration of a in same scope throws error
a is out of scope when printf is called
What is the output of this program?
#include <stdio.h>
void main()
{
int a=1, b=2, c=3, d;
d = (a=c, b+=a, c=a+b+c);
printf("%d %d %d %d", d, a, b, c);
}
11 3 5 11
11 1 5 11
11 3 2 11
11 3 3 11
Array is ______ datatype in C Programming language.
Derivative Data Type
Primitive Data Type
Custom Data Type
None of the above
What is the output of this program?
#include <stdio.h>
int main(){
printf("%d",EOF);
return 0;
}
0
1
-1
Null
What is the output of this program?
void main()
{
if(!printf(""))
printf("hello");
else
printf("world");
}
hello
world
Compilation error
None of the above
What is correct about the given program?
#include <stdio.h>
int x;
void main()
{
if (x);
else
printf("Else");
}
if block will be executed
else block will be executed
Depends on value of x since it is undeclared
Compilation Error
What is the output of this program?
void main()
{
int x=0;
for(;;)
{
if(x==3)
break;
printf("%d ",++x);
}
}
1 2 3
0 1 2 3
1 2
Compilation Error
How many times letsfindcourse will be printed?
#include <stdio.h>
int main()
{
int i = -5;
while (i <= 5)
{
if (i >= 0)
break;
else
{
i += 1;
continue;
}
printf("letsfindcourse");
}
return 0;
}
5 times
10 times
0 times
Infinite times
