Test I
Ques 1 : What is the output of the below program.
main()
{
int m=33,n=21;
m=m++ + n++;
n= ++m + ++n;
printf("%d %d",m,n);
}
Options:
(A) 55 78
(B) 57 80
(C) 58 79
(D) 60 78
Ques 2 : What will be output for program below mentioned:
main()
{
int s=5;
printf("%d,%d,%d",s,s<<3,s>>1);
}
Options:
(A) 5,40,2
(B) 5,38,3
(C) 4,44,3
(D) 5,40,4
Ques 3 : For the below program what is the correct answer?
main ()
{
int m, n, p;
m = 2;
n =4*(m++);
p =3*(++m);
}
Options:
(A) n = 8, p = 12.
(B) m = 7, p = 13.
(C) n = 9, p = 12.
(D) m = 8, n = 8.
Ques 4 : How many iterations the below loop will run
main()
{
int k;
k=0;
do
{
k--;
printf("%d",k);
++k;
}
while(k>=0);
}
Options:
(A) 77
(B) Infinite
(C) Compilation Error
(D) 0
Ques 5 : what would be the output if ch = 'D' ?
switch(ch)
{
case 'D' : printf("Wonder");
case 'S' : printf("Good");
case 'R' : printf("Welcome");
break;
}
Options:
(A) Wonder
(B) WonderGood
(C) WonderGoodWelcome
(D) None of the above
Ques 6 : x,y,z are integer variables with values 2,4,6 respectively.
What is the result of the below expression:
!((x+y)>(z+10))
Options:
(A) 1
(B) 4
(C) 12
(D) 0
Ques 7 : For the below program, How many times "www.ptinstitute.in" printed?
main ()
{
int e, r;
for (e=5, r=1; e ==4, r < 10; e --, r++)
printf("\n www.ptinstitute.in");
}
Options:
(A) 5
(B) compilation error
(C) 9
(D) None of the above
Ques 8 : What value will be printed for the program below.
main()
{
int f,m,h;
f=21;
m=32;
h=printf("%d",f) + ++m;
printf("%d",h);
}
Options:
(A) 2133
(B) 2032
(C) 2135
(D) Compilation Error
9 : How many times the below loop will get executed?
main()
{
int s;
for(s=9;s;s=s-4)
{
printf("\n%d",s);
}
}
Options:
(A) 2
(B) 3
(C) Error
(D) Infinite
Ques 10 : What is the result printed for the below statement if x=12
printf("%d %d",x, !x--);
Options:
(A) 11 0
(B) 12 12
(C) 12 0
(D) 0 12
Ques 11 : What shall be the output
main()
{
int e;
e = 13;
if(e == 21 || 20)
{
printf("Correct");
}
else
{
printf("Wrong");
}
}
Options:
(A) Correct
(B) Worng
(C) Compiler Error
(D) Run time Error
Ques 12 : What is the output for the below program?
main()
{
if(22,0,23)
{
printf("True");
}
else
{
printf("False");
}
}
Options:
(A) True
(B) False
(C) Syntax Error
(D) Compiler Error
Ques 13 : What shall be the output for the below code?
main()
{
int g, h, *p, *q`;
g = 10;
h = 10;
p = &g;
q = &h;
if(p == q)
{
printf("one");
}
else
{
printf("zero");
}
}
Options:
(A) one
(B) zero
(C) Compiler Error
(D) Syntax Error
Ques 14 : How many times the for loop will get executed in the below program?
main()
{
int a;
for(a=12, a=8; a>=0; a--)
{
printf("\n %d", a);
}
}
Options:
(A) 1
(B) 8
(C) 9
(D) Syntax Error
Ques 15 : How many iterations main() will be called?
main()
{
printf("\n Main function is Called ");
main();
}
Options:
(A) 100
(B) 1000
(C) 1
(D) Infinite
Ques 16 : What shall be the output for the program below if the base address of array is 0x2300.
main()
{
int arr[] = { 5,4,7,8,9 };
int w,*q ;
q = arr;
for(w = 0; w<=4 ; w++)
{
printf("\n 0x%x", *q++);
}
}
Options:
(A) 5 4 7 8 9
(B) 4 5 8 9
(C) 0x2300 0x2301 0x2302 0x2303
(D) 0x2301 0x2302 0x2303 0x2304
Ques 17 : Which of the following program structure/component/statement is not a concept for implementation of modularization ?
Options:
(A) DLL
(B) Functions
(C) type casting
Ques 18 : What will be output for the below program?
#include
int main()
{
int i = 340;
char *q;
q = (char *)&i;
printf("%d",*q);
return 0;
}
Options:
(A) 1
(B) 340
(C) 84
(D) Syntax Error
Ques 19 : What will be output when you will execute following c code?
#include
{
char str[10]="The American King";
printf("%s", str);
return 0;
}
Options:
(A) The Americ
(B) The
(C) Syntax error
(D) None of the aboce
Ques 20 : What is the output result of the below c program?
#include "stdio.h"
int main()
{
int _ = 3;
int __ = 13;
int ___;
___ = _ + __;
printf("%i", ___);
}
Options:
(A) 3
(B) 13
(C) 16
(D) Compilation Error
Answers
1. (A) 55 78
2. (A) 5,40,2
3. (A) n = 8, p = 12.
4. (B) Infinite
5. (C) WonderGoodWelcome
6. (A) 1
7. (C) 9
8. (C) 2135
9. (D) Infinite
10. (A) 11 0
11. (A) Correct
12. (A) True
13. (B) zero
14. (C) 9
15. (D) Infinite
16. (A) 5 4 7 8 9
17. (C) type casting
18. (C) 84
19. (A) The Americ
20. (C) 16