1) What will be the output of following program ?
1 #include < stdio.h >
2 void main()
3 { unsigned char var=0;
4 for(var=0;var<=255;var++)
5 {
6 printf("%d ",var);
7 }
8 }
1. 0 1 2 ... infinite times
2. 0 1 2 ... 255
Answer
2) What will be the output of following program ?
1 #include <stdio.h>
2 void main()
3 {
4 char cnt=0;
5 for(;cnt++;printf("%d",cnt)) ;
6 printf("%d",cnt);
7 }
1. 0 1 2 ... infinite times
2. 0 1 2 ... 127
3. 0
4. 1
Answer
3) What will be the output of following program ?
1 #include <stdio.h>
2 void main()
3 {
4 int i=1;
5 while (i<=5)
6 {
7 printf("%d",i);
8 if (i==5)
9 goto print;
10 i++;
11 }
12 }
13 fun()
14 {
15 print:
16 printf("includehelp.com");
17 } /
1. Error
2. 12345includehelp.com
3. 1234includehelp.com
4. 1includehelp.com 2includehelp.com 3includehelp.com 4includehelp.com
5includehelp.com
Answer
4) What will be the output of following program ?
1 #include < stdio.h >
2 int main()
3 {
4 int tally=0;
5 for(;;)
6 {
7 if(tally==10)
8 break;
9 printf("%d ",++tally);
10 }
11 return 0;
12 }
1. 0 1 2 3 4 5 6 7 8 9 10
2. 0 1 2 3 ... infinite times
3. 1 2 3 4 5 6 7 8 9 10
4. 1 2 3 4 5 6 7 8 9
Answer
5) What will be the output of following program ?
1 #include <stdio.h>
2 void main()
3 {
4 int tally;
5 for(tally=0;tally<10;++tally)
6 {
7 printf("#");
8 if(tally>6)
9 continue;
10 printf("%d",tally);
11 }
12 }
1. #0#1#2#3#4#5#6###
2. #0#1#2#3#4#5#6#7#8#9#10
3. #0#1#2#3#4#5##7#8#9#10 /
4. #0#1#2#3#4#5#
Answer
6) What will be the output of following program ?
1 #include <stdio.h>
2 void main()
3 {
4 int i,j,charVal='A';
5
6 for(i=5;i>=1;i--)
7 {
8 for(j=0;j< i;j++)
9 printf("%c ",(charVal+j));
10 printf("\n");
11 }
12 }
1.
A B C D E
A B C D E
A B C D E
A B C D E
A B C D E
2.
A B C D
A B C D
A B C D
A B C D
3.
A B C D
A B C
A B
A
4.
A B C D E
A B C D
A B C
A B
A
Answer
/
7) What will be the output of following program ?
1 #include <stdio.h>
2 void main()
3 {
4 int cnt=1;
5 do
6 {
7 printf("%d,",cnt);
8 cnt+=1;
9 }while(cnt>=10);
10 printf("\nAfter loop cnt=%d",cnt);
11 printf("\n");
12 }
1. After loop cnt=1
2. 1,
After loop cnt=2
3. After loop cnt=2
Answer
8) What will be the output of following program ?
1 #include <stdio.h>
2 void main()
3 {
4 int cnt=1;
5 while(cnt>=10)
6 {
7 printf("%d,",cnt);
8 cnt+=1;
9 }
10 printf("\nAfter loop cnt=%d",cnt);
11 printf("\n");
12 }
1. After loop cnt=1
2. 1,
After loop cnt=2
3. After loop cnt=2
Answer
9) What will be the output of following program ?
1 #include <stdio.h>
2 #define TRUE 1 /
3 int main()
4 {
5 int loop=10;
6 while(printf("Hello ") && loop--);
7 }
1. Hello
2. Hello Hello Hello Hello ... (Infinite times)
3. Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello (10 times)
4. Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello (11
times)
Answer
10) What will be the output of following program ?
1 #include <stdio.h>
2 int main()
3 {
4 int i=1;
5 while(i<=10 && 1++)
6 printf("Hello");
7 }
1. Error: lvalue required as increment operand
2. HelloHello ... 10 times
3. HelloHello ... 11 times
4. Hello
Answe