WorksheetsC Loops
Total questions: 25
Worksheet time: 13mins
How many loops are there in C?
2
3
4
1
What is currect syntax of for loop?
for(initialization;condition; increment/decrement)
for(increment/decrement; initialization; condition)
for(initialization, condition, increment/decrement
None of These
The statement i++; is equivalent to
i = i + i;
i = i + 1;
i = i - 1;
i --;
What's wrong? for (int k = 2, k <=12, k++)
the increment should always be ++k
the variable must always be the letter i when using a for loop
there should be a semicolon at the end of the statement
the commas should be semicolons
If you want a user to enter exactly 20 values, which loop would be the best to use?
while
switch
do-while
for
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
Which of the following is NOT a comparison operator in C++ language?
>
<=
=
==
What will be the output of this code?
OK
KO
Depends on compiler
Depends on standard
What is the value of "z" in this code?
The value of z is 10
The value of z is 15
The value of z is 15.6
The value of z is 16
What is output of below program?
int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++)
{
count++;
}
printf("%d",count);
return 0;
}
5
4
1
0
Number of Keywords present in C Language are .?
32
34
62
64
What is the only function all C programs must contain?
start()
system()
main()
Program()
What is the output of C Program.?
int main()
{
int a;
for(a=25; a <= 27; a++)
{
printf("%d ", a);
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
What is the result after execution of the following code if a is 10, b is 5, and c is 10?
if ((a > b) && (a <= c))
a = a + 1;
else
c = c+1;
a = 10, c = 10
a = 11, c = 10
a = 10, c = 11
a = 11, c = 11
In switch statement Case Labels must ends with --------
;
:
,
}
----------------- are used in C programming to manipulate the data at bit level
Logical operator
Bitwise operator
Additional operators
None of the above
Every C statement ends with ------------?
.
;
,
}
4. Name the one which is not a looping statement
for
while
do-while
if
The conditional operator are also known as
Relational operator
Binary operator
Ternary operator
Chary operator
What will be the output of following code- for(int i = 1; i < 5; i++ )
{
printf("%d",i);
}
13
135
1234
12345
Select different parts of "for" looping statement-
Initialization part
Condition Part
Update part
All of these
This loop starts counting down from 10
for(int i=10; i>0; i--)
int i = 10;
count=10;
for(int i=0; i>0; i--)
Statement lets you run code many times while a condition is true
When
Condition
for
Parentheses
What output is produced by the following segment of code:
for (int i = 0; i < 12; i++)
printf("%d ", i );
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5
6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
Infinite Loop
