C Programming for loop predict output (MCQs) Set - 1
1. Predict output of following C program:#include <stdio.h>
void main()
{
int c = 0;
for (c)
printf("Top C Practicals");
}
A. Compile time error
B. Top C Practicals
C. no output
D. none of these
2. Predict output of following C program:
#include <stdio.h>
int main()
{
int i = 0;
for ( ; i<5 ; i++)
printf("%d ", i);
return 0;
}
A. 0 1 2 3 4
B. 1 2 3 4 5
C. Compile time error
D. none of these
3. Predict output of following C program:
#include <stdio.h>
int main()
{
int i=0, j=5;
printf("Hello ");
for (i; i>j; i++)
printf("%d ", i);
printf("Students ");
return 0;
}
A. Hello 0 1 2 3 4 Students
B. Hello Students
C. Hello 0 1 2 3 4
D. 0 1 2 3 4 5
4. Predict output of following C program:
#include <stdio.h>
int main()
{
int i;
for (i=0; i<10; i++)
printf("%d ", ++i);
return 0;
}
A. 1 3 5 7 9
B. 0 1 2 3 4 5 6 7 8 9
C. 2 4 6 8
D. 2 4 6 8 10
5. Predict output of following C program:
#include <stdio.h>
int main()
{
int i;
for (i=65; i<70; i++)
printf("%c ", i);
return 0;
}
A. 65 66 67 68 69
B. A B C D E
C. Compile time error
D. Run time error
Check your answer here.
* * * * *
No comments:
Post a Comment