NEW
Font size
WorksheetsC second module quiz
Total questions: 25
Worksheet time: 4mins
Which of the following is conditional statement in C
if
int
printf
scanf
a=4;
if(a%2==0)
printf("%d is even",a);
else
printf("%d is odd",a);
Write output of the above code
4 is even
a is even
4 is odd
a is odd
switch(expression)
{
case value1:
//code to be executed; break; //optional
case value2:
//code to be executed;break; //optional
…..
……
default:
//code to be executed if all cases are not matched;
}
The above code is syntax of switch statement.True or false
False
True
..................... is an alternative to mulifiple if else if statement
for
if else
do while
switch
This is flowchart of
if
if else
switch
for
.................. is an entry controlled loop
while
do while
switch
................. is an exit controlled loop
while
do while
for
switch
for ( initialization; condition; update)
{
statement(s);
}
This syntax is correct. True or false
False
True
for(i=0;i<5;i++)
{
printf("%d", i);
}
How many times the above code executed?
0
2
5
4
for(i=0;i<5;i++)
{
printf("%d\t", i);
}
What is the output of above code
0
0 1 2
0 1 2 3 4
0 1 2 3 4 5
Syntax of while loop
while(condition);
{
statements;
}
while(condition)
{;
statements;
}
while(condition)
{
statements;
}
while(condition)
{
statements;
};
This is the flowchart of ...... statement
while
do while
for
................... is an unconditional control statement
if
if else
switch
break
................... is a group of elements of same data type
while
do while
for
array
How to declare one dimensional array
int a;
int a(50);
int a[50];
int a{50};
In general one dimensional array element is accessed by ..........
a(i)
a[i]
a{i}
a*i
Array is usually processed with ............ loops
for
while
do while
switch
How many for loops are required to input one dimensional array
0
1
2
3
How many for loops are required to input two dimensional array elements
0
1
2
3
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf(“1 \t");
}
printf(“\n”);
}11
Write output of above code
1
1
1 1
1
1 1
1 1 1
1 1
Two dimensional array elements are accessed by ..................
a
a[i]
a[i][j]
a(i)(j)
How many locations are created using this statement
int a[50];
10
20
40
50
How many locations are created using this statement
int a[20][20];
20
30
40
50
To input 5 numbers, which code is used
for(i=1;i<=5;i++)
{
scanf("%d",a[i]);
}
for(i=1;i<=5;i++)
{
printf("%d",a[i]);
}
for(i=1;i<=5;i++)
{
scanf("%d",a*i);
}
To output 5 numbers, which code is used
printf("d",i)
for(i=1;i<=5;i++)
printf("%d",a[i]);
for(i=1;i<=5;i++)
scanf("%d",a[i]);
