C Programs (GATE)
Practice questions for predicting C program outputs - GATE exam preparation
Questions
Find the output of the following C program:
main(){int i=0;while(++i<=10) printf(%d, i);}
- 1 to 10
- 0 to 9
- 1 to 9
- 0 to 10
- None of these
Find the output of the following C program:
main(){int i=0;while(i++<10)printf(%d,i);}
- 0 to 9
- 1 to 10
- Syntax error
- Infinite loop
- None of these
Find the output of the following C program:
main(){extern int i;i=20;printf(%d,sizeof(i));}
- 2
- 4
- Would vary from compiler to compiler
- Error
- None of these
Find the output of the following C program:
Main(){int i;For(i=1;i <=10;i ++){Printf(%d ”,i);i=i+1;}}
- 1 to 10
- 1 to 9
- 0 to 9
- Syntax error
- None of these
Find the output of the following C program:
Main(){int i;For(;i <=10;i ++){printf(%d ”,i);}}
- 1 to 10
- 0 to 9
- 1 to 9
- Infinite loop
- None of these
Find the output of the following C program:
main(){printf(%c, abcdefgh[4]);}
- Error
- d
- e
- abcdefgh
- None of these
Find the output of the following C program:
main(){extern int a;printf(%d, a);}int a =20;
- 0
- 20
- Error
- Garbage value
- None of these
Find the output of the following C program:
main(){int x=10,y=10,z=5,i;i=x}
- 1
- 0
- Error
- 5
- None of these
Find the output of the following C program:
main(){char str[7]=Strings;printf(%s,str);}
- Infinite loop
- Strings
- Cannot be predicted
- Error
- None of these
Find the output of the following C program:
main(){printf(5+Fascimile);}
- Error
- Fascimile
- Mile
- Fasci
- None of these
Find the output of the following C program:
Main(){int i;For(i=1;i <=10;i ++);{Printf(%d ”,i);i=i+1;}}
- Infinite loop
- Syntax error
- 1 to 10
- 1 to 9
- None of these
Find the output of the following C program:
main(){char ch='A';printf(%d%d,sizeof(ch),sizeof(A));}
- 1 1
- 1 2
- 2 2
- 2 1
- Error
Find the output of the following C program:
main(){int i=2;printf(%d %d,++i,++i);}
- 3 4
- 4 3
- 4 4
- Output may vary from compiler to compiler
- None of these
Find the output of the following C program:
main(){printf(hello);main();}
- Infinite loop
- 32767 times
- 65535 times
- Error
- Till the stack doesn't overflow
Find the output of the following C program:
main(){int a[5]={2,3};printf(%d%d%d,a[2],a[3],a[4]);}
- Garbage value
- 2 3 3
- 3 2 2
- 0 0 0
- None of these