Sei sulla pagina 1di 37

1. What is the output of the program?

void main ( )
{
struct xyz
{
char c[5];
int x;
}abc[];
abc[]={"lird",10,"labs",20,"research",30};
printf("%s",abc[1].c);
printf(",%d",abc[2].x);
}
(a).
(b).
(c).
(d).

error
labs,20
labs,30
labs,10

2. What is the output of the program?


int add (int x);
void main( )
{
int y;
y=add(3);
clrscr();
printf("%d",y);
}
add(int x)
{
return (x--);
}
(a).
(b).
(c).
(d).

4
3
2
error

3. What is the output of the program?


void main( )
{
char a;
int b;
short c;
double d;
clrscr();
a=b=0;
c=d=1;
a++;--b;c++;--d;
printf("%p,%p,%p,%p",a,b,c,d);
}

(a).
(b).
(c).
(d).
(e).

error
%p,%p,%p,%p
1,-1,2,0
junk values
0001,FFFF,0002,0000

4. What is the output of the following?


void main()
{
/* Hai buddies / Hai once again*/ */
}
(a).Will compile
(b).Will not compile
5. What is the output of the program?
#define FALSE 0
#define TRUE -1
#define HAI 1
void main()
{
int x=1,y=2;
clrscr();
if(FALSE,HAI,TRUE)
{
printf("%d",x+y);
}
else
printf("sorry");
}
(a)
(b)
(c)
(d)

syntax error
3
sorry
runtime dependent

6. What is the output of the program?


void main()
{
char a[10]="domain",b[10]="system";
puts(strcat(a,b));
printf("%s",strcat(a,b));
}
(a). domainsystem
domainsystem
(b). domainsystem domainsystem
(c). domainsystem
domainsyst
(d). error

7. What is the output of the following program?


void main()
{
static int x,y,z;
auto int a,b,c;
static int bx[1];
register int cash[1];
a=1;b=2;c=3;cash[0]=1;
clrscr( );
printf("s:%d%d%d",x,y,z);
printf(",ns:%d%d%d",a,b,c);
printf(";s:%d%d",bx[0],bx[1]);
printf(",ns:%d,%d",cash[0],cash[1]);
getch( );
}
(a).
(b).
(c).
(d).

s:111,ns:123;s:11,ns:1,0
s:000,ns:123;s:00,ns:1,1
s:000,ns:123;s:00,ns:1,junk value
s:111,ns:123;s:11,ns:1,junk value

8. Give the output of the program?


void main()
{
char box[3],*c_ptr;
int cash[3],*i_ptr;
clrscr( );
c_ptr=box-5;
printf("c_ptr(bf):%u",c_ptr);
c_ptr=c_ptr+1;
printf(",c_ptr(af):%u",c_ptr);
i_ptr=cash+4;
printf("\ni_ptr(bf):%u",i_ptr);
i_ptr=i_ptr-1;
printf(",i_ptr(af):%u",i_ptr);
getch();
}
Assume box address = 65522
Assume cash address = 65516
(a). c_ptr(bf):65517,c_ptr(af):65518
i_ptr(bf):65520,i_ptr(af):65519
(b). c_ptr(bf):65517,c_ptr(af):65518
i_ptr(bf):65524,i_ptr(af):65522
(c). c_ptr(bf):65511,c_ptr(af):65513
i_ptr(bf):65524,i_ptr(af):65522
(d). c_ptr(bf):65517,c_ptr(af):65519
i_ptr(bf):65520,i_ptr(af):65518

9. What is the output of the program?


void main()
{
float a=1,b=2,r1;
float x=10,y=20,r2,r3;
clrscr();
r1=(char)(a/b);
r2=x/y;
r3=(char)a/b;
printf("r1=%f",r1);
printf(",r2=%f",r2);
printf(",r3=%f",r3);
}
(a).
(b).
(c).
(d).
(e).

junk value
0.500000,0.500000,r3=0.500000
0.500000,0.500000,r3=0.000000
0.000000,0.500000,r3=0.500000
0.000000,0.500000,r3=0.000000

10. What is the output of the program?


void main()
{
char c[10]="JIKA";
clrscr();
printf(",s%d",printf(",%d",printf("%s",c)));
printf("%d",printf(","));
}
(a).
(b).
(c).
(d).
(e).

,s2,1,JIKA,
,s2,1,JIKA,4,
JIKA,4,s2,1
JIKA,,s,1
error

11. What is the output of the program?


void main()
{
float x=0.0;
clrscr();
if(--x,++x)
printf("one");
if(x++,--x)
printf("two");
if(++x,x++)
printf("three");
x-=3;
if(x,--x)
printf("four");
getch( );
}

(a).
(b).
(c).
(d).
(e).

onetwothreefour
onetwothree
threefour
onetwofour
twothreefour

12. What is the output of the program?


#include<stdio.h>
void main()
{
int x,y,z;;;
x=0;y=1;z=2;;;;
x=y+z;
clrscr();
printf("%d",x);
printf(",%d",y);
getch( );
}
(a). will compile
(b). will not compile
13. What is the output of the program?
void main()
{
float f=89.9732143876f;
int k=65536+32768;
clrscr();
printf("\n%e,%.e,%g",f,f,f);
printf(",%d",k);
}
(a).
(b).
(c).
(d).
(e).

9.997321e+01,9e+01,89.9732,-32768
8.997321e+01,9e+01,89.9732,-32768
9.997321e+01,9.0e+01,89.9732,98304
9.997321e+01,9.e+01,89.9732,98304
8.997321e+01,9.e+01,89.9732,98304

14. What is the output of the program?


int main()
{
char box[]="R123";
clrscr();
puts(box);
printf("%s",box);printf("%s",box);
return 0;
}

(a). R123R123R123
(b). R123R123
(c). R123R123
R123
(d). R123
R123R123
15. What is the output of the program?
void main()
{
char start,*show,*end;
clrscr();
end=(char*)(show(char*)strcpy(start,"MISPIS,"));
printf("%s%s%s",start,show,end);
getch();
}
(a). MISPIS,MISPIS,MISPIS,
(b). MISPIS,junk value
(c). error
(d). MISPIS,MISPIS,junk value
16. What is the output of the program?
_fastcall float sum(int a, int b);
main ( )
{
sum(-3,5);
}
_fastcall float sum(int a, int b)
{
float c;
c=a+b;
printf("%f",c);
}
(a).
(b).
(c).
(d).
(e).

junk value
2.000000
works under windows
works under OS/2
c and d

17. What is the output of the program?


# include<string.h>
void main()
{
char zone[]="kargil";
char target[]="kargil";
char result;
clrscr();
result=(strcmp(zone,target))?1:0;
if(result)
printf("EQUAL");

else
printf("NOT EQUAL");
getch( );
}
(a).
(b).
(c).
(d).

NOT EQUAL
EQUAL
compiles and no answer
compiles but don't run

18. Give the output of the following?


void main()
{
char t1[10];
t1="craft";
printf("%s",t1);
}
(a).
(b).
(c).
(d).

craft
craf
Lvalue required
raft

19. What is the output of the program?


void main()
{
char ptr1[]="goat";
char ptr2[]="good";
clrscr();
if(strcmp(ptr1,ptr2)>0)
printf("good job");
else
printf("nice job");
}
(a). good job
(b). nice job
(c). error
20. What will be the output?
void main()
{
char *text;
char buffer[50]="1234567890";
int arr[6]={1,2,3};
text=buffer;
clrscr();
printf("%d,%0.5d,%d",sizeof(buffer),sizeof(text),sizeof(a
rr));
}
(a). 50,1,6

(b). 50,2,12
(c). 10,2,12
(d). 10,1,6
21. What is the output of the program?
void main()
{
static buffer[10];
int i;
clrscr();
for(i=0;i<2;i++)
printf("%s",buffer[i]);
getch( );
}
(a).
(b).
(c).
(d).

(null)(null)
garbage value
error
0 0

22. What is the output of the program?


void main()
{
char *buffer;
buffer = "done-boss";
clrscr();
//printf("%c",buffer);
//printf("%s",buffer);
printf("%s",*(buffer+3));
getch();
}
(a).
(b).
(c).
(d).

pragram will not compile


abnormal program termination
e-boss
ne-boss

23. What is the output of the program?


void main()
{
char string[][3]={"123","456","789","012","345"};
int row,column;
clrscr();
for(row=0;row<5;row++)
{
for(column=row;string[row]!=string[column];column++)
printf("%s",string[row]);
}
printf(",");
}
(a). blank screen

(b). 123,456,789,012,345
(c). 147,032,581,436,925
(d). 123,345,456,012,789
24. What is the output of the program?
doit(int *x,int *y)
{
*x = *x**y;
*y = *y**y;
}
void main()
{
int x=10,y=2;
clrscr();
doit(&x,&y);
printf("%d,%d",x,y);
}
(a).
(b).
(c).
(d).

10,2
10,4
20,2
20,4

25. What is the output of the program?


void main()
{
unsigned char s;
unsigned c=0;
for(s=0;c!=120;c+ +100)
printf("%d,",c);
}
(a).
(b).
(c).
(d).

0,100,
error
0,0,0,0,...
0,100,200,300,...

26. What is the output of the program?


void main()
{
int *buffer[] = {"12","13","1","20","70"};
int x,y,z;
clrscr();
x =(int) buffer;
y =(int) buffer + 3;
z = x++;
printf("%d,%d,",z,y-x);
z = (x++);
printf("%d,%d",z,x-y);
getch();
}

(a).
(b).
(c).
(d).

13,8,14,-6
13,8,13,-6
error
depends on the address of the buffer

27. What is the output of the program?


void main()
{
char *axe[] = {"1","2","3"};
int result;
clrscr();
result = sizeof(axe)/sizeof(char*);
printf("%d",result);
}
(a).
(b).
(c).
(d).

3
6
2
error

28. What is the output of the program?


void swap(int *num1 , int *num2)
{
int *temp;
temp = *num1;
*num1 = *num2;
*num2 = temp;
}
void main()
{
int num1=5,num2=8;
clrscr();
swap(&num1,&num2);
printf("%d,%d",num1,num2);
getch();
}
(a).
(b).
(c).
(d).

5,8
8,5
error (no return statement in swap())
junk values

29. What is the output of the program?


void main()
{
int buffer[] = {0,0x9,8,7};
int ptr = 1;
clrscr();
printf("%d,",buffer[ptr]);
printf("%d,",ptr[buffer]);

printf("%d",buffer[ptr++]);
getch();
}
(a).
(b).
(c).
(d).

9,9,9
9,junk,9
0x9,junk,9
9,junk,8

30. What is the output of the program?


int printf(const char *,...);
void main()
{
int n1=10,n2=10,n3=50,total;
float calc;
char modified[]="calc = %f";
clrscr();
calc=((n1+n2+n3)*2)/2.0;
printf(modified,calc);
}
(a).
(b).
(c).
(d).

error (in prototyping of printf())


compiler dependent
calc = 70.000000
error (in arguement modified given to printf())

31. What is the output of the program?


void main()
{
int fox[10] = { 1,2,3,4,5,6,7,8,9,10 };
clrscr();
printf("%d,",(fox+5)+*(fox+1));
{
int fox[10] = { 1,2,3,4,5,6,7,8,9,10 };
printf("%d",(fox+5)+*(fox+1));
}
getch();
}
(a).
(b).
(c).
(d).

compiler dependent
garbage value
values depend upon the fox address
error (invalid pointer addition)

32. What is the output of the program?


void main()
{
struct stru
{
int age;

char name[15];
}detail1={22,"dass"};
union u
{
int age;
char name[15];
}detail2={11};
detail2=(union u) detail1;
printf("%d%d",detail1.age,detail2.age);
}
(a).
(b).
(c).
(d).
(e).

11,22
22,11
11,11
22,22
error

33. What is the output of the program?


void main()
{
int bit, byte=0x5;
bit = 1;
clrscr();
switch(bit & byte)
{
case 3: printf("hai!\t");
case 2: printf("everybody\t");
case 1: printf("fine");
default:printf("");
}
getch();
}
(a).
(b).
(c).
(d).

hai! everybody fine


everybody fine
fine
empty screen

34. What is the output of the program?


void main()
{
char name[3][10]= { "server", "printer","poder"};
clrscr();
printf("%s is good\n",&name[1][0]);
printf("%s is bad",name[2][0]);
getch();
}
(a). starting address of printer' is good

poder is bad
(b). printer is good
'ascii value' is bad
(c). printer is good
poder is bad
(d). p
p
35. What will be the output?
static int a=5;
void main()
{
int res=0;
clrscr();
do
{
res+=(1/a);
}while(0<a--);
printf("Result = %f",res);
getch();
}
(a).
(b).
(c).
(d).

Result = 1.000000
Divide error
Zero
Junk value

36. Give the output of the program?


main( )
{
char *abc="LIRD";
clrscr();
printf("%2.6c\t",abc);
printf("%-2.6c\t",abc);
printf("%(-2.6+1)c\t",abc);
printf("%2c\t",abc);
printf("%-2c",abc);
return 0;
}
(a). LIRD
(b). Ascii
value
(c). L I R
(d). LI LI

RD D RD
value Ascii value %(-2.6+1)c Ascii value Ascii
LI RD
LI LI

37. What is the output of the program?

void main()
{
const int k=5;
int num[20]={1,2,3,4,5};
for(k=0;k<5;k++)
printf("%d",num[k]);
}
(a).1 2 3 4 5
(b).error
(c).5
(d).none
38. What is the output of the program?
void main(argc,argv)
{
clrscr();
if(argc<1)
printf("error");
if(argc==1)
printf("no error");
else
exit(1);
}
(a).error
(b).no error
(c).Abnormal termination
(d).warning
39. What is the output of the program?
#include <stdio.h>
main()
{
char *a,b[]="operation";
clrscr();
a=b;
printf("%*a,",5,a);
printf("%*b,",4,b);
printf("%*b",6,b[3]);
getch();
return 0;
}
(a).
(b).
(c).
(d).

%*a,%*b,%*b
t,a,r
operation,operation,r
error

40. What will be the output?

#include <stdio.h>
void main()
{
char *s="hai";
clrscr();
printf("%.*,%s",s,s);
getch();
}
(a).
(b).
(c).
(d).

%.*,hai
%.*,%s
.*,hai
error

41. Give the output of the program?


main()
{
int x,y,z;
clrscr();
scanf("%d%d",x,y);
z=x+y;
printf("%d",z);
return 0;
}
Give input values: x=2,y=3
(a).
(b).
(c).
(d).

5
will not compile
empty screen
garbage value

42. What will be the output of the program?


void main()
{
int x=20,y=30;
clrscr();
if(x=6)y=7;
else y=3;
printf("%d",y);
}
(a). 7
(b). 3
(c). error

43. What is the output of the program?

#include <stdio.h>
convert(int num)
{
if(num%2) return num;
else return(10);
}
void main()
{
int num=30;
clrscr();
num=convert(num);
num=convert(num);
printf("%d",num);
getch();
}
(a).
(b).
(c).
(d).

error
0
30
10

44. What is the output of the program?


#include <stdio.h>
void main()
{
unsigned int a=0;
clrscr();
while(a>=0)
{
printf(" %u ",a);
a--;
}
getch();
}
(a).
(b).
(c).
(d).
(e).

0,65535,65534,...
empty screen
0,65535,65533,...
0,65534,65532,...
0,garbage values...

45. What will be the output of the following program?


#include <stdio.h>
void main()
{
int bat[5]={1,2,3,4,5},*bate;
clrscr();

bate=&bat[5];
printf("%d",bate[-1]);
getch();
}
(a).
(b).
(c).
(d).
(e).
(f).
(g).

5
4
3
2
1
error
garbage value

46.

What is the output of the following program?

#include <stdio.h>
int zip(int n)
{
if(n<=1) n=1;
else n=zip(n-3)+zip(n-1);
return n;
}
void main()
{
int a;
clrscr();
a=zip(6);
printf("%d",a);
getch();
}
(a).
(b).
(c).
(d).
(e).

5
6
7
8
9

47. .What is the output of the following program?


#include <stdio.h>
void main()
{
int x;
clrscr();
switch(x)
{
case 0:printf("ST");
case 1:printf("Hai");
case 2:printf("Bye");
default:printf("Wrong");
}

getch();
}
(a). ST
(b). STHaiByeWrong
(c). Wrong
48. What is the output of the following program?
#include <stdio.h>
void main()
{
int j;
clrscr();
switch(j=6)
{
case 1:printf("one");break;
case 2:printf("two");break;
case 1+2+3:printf("last");break;
default:printf("Wrong");break;
}
getch();
}
(a).
(b).
(c).
(d).

one
last
Wrong
error

49. What is the output of the following program?


#include <stdio.h>
void main()
{
int buddy,dummy = 0;
buddy=1;dummy=0;
clrscr();
if((buddy=0) && (dummy=1))
printf("buddy is good");
else
printf("dummy is good");
getch();
}
(a).
(b).
(c).
(d).

buddy is good
dummy is good
possibly incorrect assignment
error

50. What is the output of the following program?

#include <stdio.h>
void main()
{
char x=0xA;
int y;
clrscr();
y=(int)x;
printf("%d",y);
y=y>>2;
printf(",%d",y);
getch();
}
(a).
(b).
(c).
(d).

65,16
10,2
garbage values
error

51. What is the output of the following program?


#include <stdio.h>
void main()
{
clrscr();
fn(5);
getch();
}
int fn(int x)
{
if(x<=0)
return;
else fn(x-1)+x;
printf(" %d ",x);
return;
}
(a).
(b).
(c).
(d).
(e).

returns
1 2 3 4
error
5 4 3 2
0 1 2 3

nothing
5
1
4 5

52. What is the output of the following program?


#include <stdio.h>
void main()
{
char n[]="stumped",*t;
char *p="123";

clrscr();
t=malloc(strlen(p)+1);
strcpy(t,n);
printf("%s",t);
getch();
}
(a).
(b).
(c).
(d).
(e).

stu
stum
stump
stumped
error

53. What is the output of the following program?


#include <stdio.h>
void main()
{
int a=0,b,x,y;
b=~0;x=-1;y=-0;
clrscr();
if(b==x) printf(" 1 ");
else
printf(" 2 ");
if(b==y) printf(" 3 ");
else
printf(" 4 ");
getch();
}
(a).
(b).
(c).
(d).

1,4
2,4
1,3
2,3

54. What is the output of the following program?


#include <stdio.h>
struct x
{
int x:8;
float y;
char d;
}sx;
struct y
{
int x:9;
float y;

char d;
}sy;
void main()
{
clrscr();
printf("%d",sizeof(sx));
printf(",%d",sizeof(sy));
getch();
}
(a).
(b).
(c).
(d).

7,8
13,14
6,7
7,7

55. What will be the output of the following program?


#include <stdio.h>
void main()
{
char *p="a";
int
int
int
int

j=100+p;
k=100/p;
l=100*p;
m=100-p;

//L-2
//L-3
//L-4
//L-5

}
(a).
(b).
(c).
(d).
(e).
(f).

Error
Error
Error
Error
Error
Error

at
at
at
at
at
at

L-2,L-3
L-3,L-4
L-2,L-3,L-4,L-5
L-2,L-3,L-5
L-3,L-4,L-5
L-3,L-4

56. What is the output of the following program?


#include <stdio.h>
void main()
{
char *s;
int l;
clrscr();
s=(char *)malloc(20);
s="techcampus";
l=strlen(s);
printf("%d",l);
getch();
}
(a). Error

(b). 10
(c). 20
57. What is the output of the following program?
#include <stdio.h>
void main()
{
struct n{int num;char name[15];};
struct n x[]={{16,"face"},{10,"sati"},{9,"fire"}};
clrscr();
printf("%d,%d",x[1].num,(*(x+1)).num+1);
getch();
}
(a).10,9
(b).10,10
(c).error
(d).10,11
58. What is the output of the following program?
#include <stdio.h>
#define product(n1,n2) n1*n2
void main()
{
int a,b,c;
a=b=2;
clrscr();
c=product(a+2,b+1);
printf("%d",c);
getch();
}
(a). 7
(b). 12
(c). Error : Lvalue required
59. What is the output of the following program?
#include <stdio.h>
void main()
{
int a=5,b=5,c=6,res;
clrscr();
res=(a>b)?(a>c):(c>b)?b:(a>b)?(a>c):(c>b)?b:c;
printf("%d",res);
getch();
}
(a). Error

(b).
(c).
(d).
(e).

5
6
0
1

60. What is the output of the following program?


#include <stdio.h>
void main()
{
int box[200];
clrscr();
printf("%d",*(box-(*box+20)));
getch();
}
(a). Error
(b). Garbage value
(c). 0
61. What is the output of the following program?
#include <stdio.h>
void main()
{
static int x=1;
int res=0;
clrscr();
do
{
res=(1/x);
printf("%d ",res);
}while(0<x--);
getch();
}
(a). Endless loop
(b). Divide by zero error
(c). 1 Divide by zero error
62. What is the output of the program?
void main()
{
int x=10,y=200;
x=--y;
x+=y;
+y-=--x;
printf("%d,%d\n",x,y);
getch( );
}
(a). 209,-7

(b).
(c).
(d).
(e).

397,-198
397,596
3977,596
397,198

63. What is the output of the program?


main()
{
char a[]="dass";
char b[]="das";
clrscr();
printf("%s,%s",a,b);
printf(",%x,",sizeof(a),sizeof(b));
return 0;
}
(a).
(b).
(c).
(d).
(e).

dass,das,5,4
dass,das,4,3
dass,das,5,
dass,das,%x,
error

64. What is the output of the program?


void main()
{
char c[5];
*c=1;
*c[1]='b';
printf("%d",&c[1]-c);
printf("%c",&c[1]-c);
}
(a).
(b).
(c).
(d).

error : Invalid indirection


garbage value
1,b
1,garbage value

65. What is the output of the program?


# include<stdio.h>
void main()
{
FILE *fp;
fp=fopen("DATA.DAT","w");
fprintf(fp,"hai\n");
fclose(fp);
fp=fopen("DATA.DAT","w");
fprintf(fp,"bye\n");
fclose(fp);
}
(a). hai

(b). haibye
(c). bye
(d). hai
bye
66. What is the output of the program?
main()
{
int x,y;
clrscr();
x=9;y=8;
if(x++,y++)
printf("%d,%d",x+y,y);
return 0;
}
(a).
(b).
(c).
(d).
(e).
(f).

17,8
17,9
18,8
18,9
19,8
19,9

67. What is the output of the program?


void main()
{
int a=-1;
clrscr();
printf("%d,%d",a,main());
printf(",%u",main());
//return 0;
}
(a).
(b).
(c).
(d).

infinite loop
error
-1,-1,1
1,1,1

68. What is the output of the program?


int main()
{
enum { north=-9,south,east=0x3,west};
clrscr();
printf("north=%d,east=%d,west=%d,south=%d",
north, east, west, south);
return 0;
}
(a). north=-9,east=3,west=1,south=0
(b). north=-9,east=3,west=2,south=1
(c). north=-9,east=3,west=0,south=0

(d). north=-9,east=3,west=4,south=-8
69. What is the output of the following program?
# include<stdio.h>
main()
{
char name[10]="brown",*s="\0";
*name=NULL;
clrscr();
if(name!=0 && s==NULL)
printf("hai");
else
printf("bye");
return 0;
}
(a).
(b).
(c).
(d).

hai
bye
junk values
error0

70. What will be the output of the program?


void main()
{
int x=10,y=20;
clrscr();
if(x&0x31)
printf("1");
else
printf("0");
}
(a).
(b).
(c).
(d).

1
0
error
empty screen

71. What is the output of the program?


#define limit 5
main()
{
int a,b;
int *x,*y;
a = 5 ; b = -9;
x=a+(--b);
y=(-limit);
//x=x+y;
clrscr();
printf("%d,%d",x,y);

return 0;
}
(a).
(b).
(c).
(d).

13,-5
14,-5
-5,-5
- 5,-5

72. What will be the output of the program?


main()
{
int x,y;
char d='';
x=3;y=9;
printf("%d",x+++y);
printf(",%d",sizeof(d));
printf(",%d",sizeof(""));
return 0;
}
(a).
(b).
(c).
(d).
(e).

13,1,1
13,0,0
13,1,0
13,0,1
error

73. What is the output of the following program?


main()
{
char name[]={"hai"};
clrscr();
printf("%s",name[0]);
return 0;
}
(a).
(b).
(c).
(d).

hai
junk values
error
h

74. What is the output of the program?


void main()
{
char a[10],b[10],c[10],d[10];
clrscr( );
// input 1 2 3 4
printf("%d",scanf("%s\n\n%s\n%s",a,b,c));
printf(",%s%s%s",a,b,c);
getch( );
}
(a). 3,123

(b). 3,1234
(c). 4,1234
(d). 4,123
75. What is the output of the given program?
void main()
{
char *x="hai";
char *y="hai friends";
while(*x= *y)
{
printf("%c,%c",*x,*y);
printf(",%s,%s",*x,*y);
}
}
(a).
(b).
(c).
(d).

h,h,hai,hai friends
infinite loop
garbage value
pointer error

76. What is the output of the program?


main()
{
char buf[]="daylight",temp;
int x,y;
clrscr();
for(x=0;y=strlen(buf),x<y;x++)
printf("hai,");
printf("%s",buf);
return 0;
}
(a).
(b).
(c).
(d).

hai,hai,hai,hai,hai,hai,hai,hai,daylight
hai,hai,hai,hai,hai,hai,hai,daylight
hai,hai,hai,hai,hai,hai,daylight
error in loop syntax

77. What is the output of the program?


int main()
{
int x,y;y=20;
clrscr();
for(x=10;x<16;x++)
{
if(y&(0x8000>>x))
printf("1,");
else
printf("2,");
}
return 0;

}
(a).
(b).
(c).
(d).

2,1,1,1,2,2,
2,2,2,1,2,2,
2,1,2,1,2,2,
2,2,2,1,1,2

78. What is the output of the following program?


#define add(n,m) n+m
#define div(x,y) x/y
main()
{
int j;
clrscr();
j=2*add(6,div(4,2));
printf("%d",j);
return 0;
}
(a).
(b).
(c).
(d).
(e).

16
15
14
13
12

79. What is the output of the program?


int
{

main()
int array[]={ 5,6,7,8 };
int *handle = array;
clrscr();
*(array+3) = *++handle + *handle++;
printf("%d,%d,%d,%d",array[0],array[1],array[2],array[3])

;
return 0;
}
(a).
(b).
(c).
(d).

5,6,7,12
5,6,7,11
4,5,7,12
5,6,6,12

80. Give the output of the program?


int main()
{
int y=-1,x=0;
clrscr();
while(y)
{
y&=y-1;

x++;
}
printf("%d,%d",x,y);
return 0;
}
(a).
(b).
(c).
(d).
(e).
(f).

16,0
15,0
1,1
0,0
1,0
0,1

81. What is the output of the program?


int main()
{
int x=2;
x=(x%2);
x=!x;
x&1!=1;
x=!x;
clrscr( );
printf("%d",x);
return 0;
}
(a).
(b).
(c).
(d).

0
1
2
3

82. What is the output of the program?


main()
{
int a=1,b=2,c=3,*ht;
ht=&b;
a=b/ht;
c=b;
clrscr();
printf("a=%d,b=%d",a,c);
return 0;
}
(a).
(b).
(c).
(d).

a=1,b=1
a=1,b=0
a=0,b=0
error

83. What will be the output of the following program?


int main()
{

int x=3;
clrscr();
while(x--);
{
int x=4;
x--;
printf("%d",x);
}
return 0;
}
(a).
(b).
(c).
(d).

4321
3210
321
3

84. What is the output of the program?


int main()
{
char buf[]={'a','b','c','d','e'};
int box[]={1,2,3,4,5,6};
clrscr();
printf("%c,%d",(&buf[2],buf[0]),(&box[1]-&box[0]));
return 0;
}
(a).
(b).
(c).
(d).
(e).

a,2
a,1
b,1
b,2
error

85. What will be the output of the following program?


int main()
{
char b[20]={1,2,3,4,5};
int x;
for(x=0;x<5;x++)
{
b[x]=x+'a';
}
clrscr();
printf("%s",b);
return 0;
}
(a).
(b).
(c).
(d).

12345
abcde
a2345
error

86. What is the output of the program?

#define m(x,y) x<y?x:y


main()
{
int i=0,c[10],*p,a=1;
p=(int*)a;
while(m(p++,&c[8]<c[7]))
i=5;
clrscr();
printf("i=%d",i);
return 0;
}
(a).
(b).
(c).
(d).
(e).

infinite loop
i=5
i=5i=5i=5
i=5i=5i=5i=5
error

87. What will be the output of the following program?


int main()
{
int *i=10,*j=20;
i=(int*)((int)i*(int)j);
i=(int)i*(int)j;
clrscr();
printf("%d",i);
return 0;
}
(a).
(b).
(c).
(d).

200
2000
4000
error: Illegal use of pointers

88. What is the output of the program?


int main()
{
char buf[]="hai leaders";
int x,*hle,i;
hle=(int*) buf;
clrscr();
for(i=2;*hle;i++)
printf("%c",*hle++);
return 0;
}
(a). i leaders
(b). ai leadres
(c). hilaes

(d).

leaders

89. What will be the output of the program?


int main()
{
char *c[]={"kill","you","good","guy"};
char **sc[]={c+3,c+2,c+1,c};
char ***scc=sc;
clrscr();
printf("%s",<**--*++scc+3);
printf("%s",*scc[-2]+3);
printf("%s",scc[-1][-1]+1);
return 0;
}
(a).
(b).
(c).
(d).

illegal initialization
garbage values
error in printf statement
empty screen

90. What will be the output of the program?


int main()
{
char *c;
int *i;
c=(char*)0x99;
i=(int *)c;
i++;
c++;
clrscr();
printf("c=%x,i=%x",c,i);
return 0;
}
(a).
(b).
(c).
(d).
(e).

c=9a,i=9b
c=0x99,i=99
c=0x99,i=0x99
error
c=0x99,a=garbage value

91. What is the output of the program?


# include<conio.h>
# include<stdio.h>
int foo(int a)
{
return (a<<(a%2)&a);
}
int main()
{

int result;
clrscr();
result = foo(7);
printf("%d",result);
return 0;
}
(a).
(b).
(c).
(d).

3
6
1
0

92. What is the output of the following program?


# include<stdio.h>
# include<conio.h>
int val = 10;
int foo(int sv)
{
int val = sv/3;
return val;
}
int main()
{
val = 10;
clrscr();
printf("%d",foo(20));
return 0;
}
(a).
(b).
(c).
(d).

6
2
10
0

93. What is the output of the following program?


# include<stdio.h>
int main()
{
struct y
{
int i;
char c;
FILE *u;
}x;
clrscr();
printf("%d,",sizeof(FILE));
printf("%d",sizeof(x.u));
return 0;

}
(a).
(b).
(c).
(d).

2,2
1,2
16,2
4,2

94. What is the output of the following program?


int main()
{
char message = {'h','o','w','n','i','c','e','?'};
clrscr();
printf("age = %s",message);
return 0;
}
(a).
(b).
(c).
(d).

age = junkvalue
age = hownice?
age = h
error

95. What is the output of the program?


main(int a, static char *b[])
{
clrscr();
printf("%d,%d",a,b[1]);
return 0;
}
(a).
(b).
(c).
(d).

1,0
0,1
error
junk values

96. What is the output of the program?


int main()
{
clrscr();
f1();
f2();
}
int x=5;
f1( )
{
printf("x1 = %d,",x);
};
f2( ){
printf("x2 = %d",x);
};
(a). x1 = 5,x2= 5

(b). x1 = 5,x2 = garbage value


(c). run time error
(d). compilation error
97. Will the below program compile?
#include<stdio.h>
#include<conio.h>
short main[]={0x1075,012,6,3281689321,-10,120,'d',56789,9187};
(a). compilation error
(b). runtime error
(c). not possible declaration of main
98. What is the output of the following program?
main(int t,int a)
{
int x,y;
char *c,**s;
return!
//0<t?t<3?;
main(-79, main(18,main(-8,12)));
main(t+1,a);
main(-94,a);
return 0;
}
(a). Infiite loop
(b). compilation error
(c). runtime error
99. What is the output of the program?
int main()
{
#include<stdio.h>
#include<conio.h>
clrscr( );
printf("excellent clear");
return 0;;
}
(a).
(b).
(c).
(d).

include is not allowed inside main()


excellent clear
garbage value
empty screen

100. What is the output of the program?

int main()
{
#include<stdio.h>
#include<conio.h>
char *_[20] = {"typical program"};
clrscr( );
*_=(char *)malloc(100);
printf("%s",*_);
printf("%s",_);
return 0;
}
(a).
(b).
(c).
(d).

include
Illegal
garbage
typical

is not allowed inside main()


declaration of *_
value
program

Potrebbero piacerti anche