CSE MCQs :: C-MCQs
-
What is the output of this C code?
int main()
{
int i = 0;
do
{
i++;
if (i == 2)
continue;
printf("In while loop ");
} while (i < 2);
printf("%d\n", i);
}
-
What is the output of this C code?
int main()
{
int i = 0, j = 0;
for (i; i < 2; i++){
for (j = 0; j < 3; j++){
printf("1\n");
break;
}
printf("2\n");
}
printf("after loop\n");
}
-
What is the output of this C code?
int main()
{
int i = 0;
while (i < 2)
{
if (i == 1)
break;
i++;
if (i == 1)
continue;
printf("In while loop\n");
}
printf("After loop\n");
}
-
What is the output of this C code?
int main()
{
int i = 0;
char c = 'a';
while (i < 2){
i++;
switch (c) {
case 'a':
printf("%c ", c);
break;
break;
}
}
printf("after loop\n");
}
-
What is the output of this C code?
int main()
{
printf("before continue ");
continue;
printf("after continue\n");
}
- The following code 'for(;;)' represents an infinite loop. It can be terminated by.
- The correct syntax for running two variable for loop simultaneously is.
- Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3) ?
-
What is the output of this C code?
int main()
{
short i;
for (i = 1; i >= 0; i++)
printf("%d\n", i);
}
-
What is the output of this C code?
void main()
{
int k = 0;
for (k)
printf("Hello");
}
A.
The control won't fall into the for loop
|
B.
Numbers will be displayed until the signed limit of short and throw a runtime error
|
C.
Numbers will be displayed until the signed limit of short and program will successfully terminate
|
D.
This program will get into an infinite loop and keep printing numbers with no errors
|