Upload
santhosh-parthasarathy
View
275
Download
0
Embed Size (px)
Citation preview
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). error
(b). labs,20
(c). labs,30
(d). 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). 4
(b). 3
(c). 2
(d). 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). error
(b). %p,%p,%p,%p
(c). 1,-1,2,0
(d). junk values
(e). 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) syntax error
(b) 3
(c) sorry
(d) 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). s:111,ns:123;s:11,ns:1,0
(b). s:000,ns:123;s:00,ns:1,1
(c). s:000,ns:123;s:00,ns:1,junk value
(d). 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). junk value
(b). 0.500000,0.500000,r3=0.500000
(c). 0.500000,0.500000,r3=0.000000
(d). 0.000000,0.500000,r3=0.500000
(e). 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). ,s2,1,JIKA,
(b). ,s2,1,JIKA,4,
(c). JIKA,4,s2,1
(d). JIKA,,s,1
(e). 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). onetwothreefour
(b). onetwothree
(c). threefour
(d). onetwofour
(e). 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). 9.997321e+01,9e+01,89.9732,-32768
(b). 8.997321e+01,9e+01,89.9732,-32768
(c). 9.997321e+01,9.0e+01,89.9732,98304
(d). 9.997321e+01,9.e+01,89.9732,98304
(e). 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). junk value
(b). 2.000000
(c). works under windows
(d). works under OS/2
(e). 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). NOT EQUAL
(b). EQUAL
(c). compiles and no answer
(d). compiles but don't run
18. Give the output of the following?
void main()
{
char t1[10];
t1="craft";
printf("%s",t1);
}
(a). craft
(b). craf
(c). Lvalue required
(d). 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). (null)(null)
(b). garbage value
(c). error
(d). 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). pragram will not compile
(b). abnormal program termination
(c). e-boss
(d). 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). 10,2
(b). 10,4
(c). 20,2
(d). 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). 0,100,
(b). error
(c). 0,0,0,0,...
(d). 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). 13,8,14,-6
(b). 13,8,13,-6
(c). error
(d). 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). 3
(b). 6
(c). 2
(d). 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). 5,8
(b). 8,5
(c). error (no return statement in swap())
(d). 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). 9,9,9
(b). 9,junk,9
(c). 0x9,junk,9
(d). 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). error (in prototyping of printf())
(b). compiler dependent
(c). calc = 70.000000
(d). 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). compiler dependent
(b). garbage value
(c). values depend upon the fox address
(d). 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). 11,22
(b). 22,11
(c). 11,11
(d). 22,22
(e). 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). hai! everybody fine
(b). everybody fine
(c). fine
(d). 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). Result = 1.000000
(b). Divide error
(c). Zero
(d). 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 RD D RD
(b). Ascii value Ascii value %(-2.6+1)c Ascii value Ascii
value
(c). L I R LI RD
(d). LI LI 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). %*a,%*b,%*b
(b). t,a,r
(c). operation,operation,r
(d). error
40. What will be the output?
#include <stdio.h>
void main()
{
char *s="hai";
clrscr();
printf("%.*,%s",s,s);
getch();
}
(a). %.*,hai
(b). %.*,%s
(c). .*,hai
(d). 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). 5
(b). will not compile
(c). empty screen
(d). 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). error
(b). 0
(c). 30
(d). 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). 0,65535,65534,...
(b). empty screen
(c). 0,65535,65533,...
(d). 0,65534,65532,...
(e). 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). 5
(b). 4
(c). 3
(d). 2
(e). 1
(f). error
(g). 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). 5
(b). 6
(c). 7
(d). 8
(e). 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). one
(b). last
(c). Wrong
(d). 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). buddy is good
(b). dummy is good
(c). possibly incorrect assignment
(d). 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). 65,16
(b). 10,2
(c). garbage values
(d). 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). returns nothing
(b). 1 2 3 4 5
(c). error
(d). 5 4 3 2 1
(e). 0 1 2 3 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). stu
(b). stum
(c). stump
(d). stumped
(e). 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). 1,4
(b). 2,4
(c). 1,3
(d). 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). 7,8
(b). 13,14
(c). 6,7
(d). 7,7
55. What will be the output of the following program?
#include <stdio.h>
void main()
{
char *p="a";
int j=100+p; //L-2
int k=100/p; //L-3
int l=100*p; //L-4
int m=100-p; //L-5
}
(a). Error at L-2,L-3
(b). Error at L-3,L-4
(c). Error at L-2,L-3,L-4,L-5
(d). Error at L-2,L-3,L-5
(e). Error at L-3,L-4,L-5
(f). Error at 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). 5
(c). 6
(d). 0
(e). 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). 397,-198
(c). 397,596
(d). 3977,596
(e). 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). dass,das,5,4
(b). dass,das,4,3
(c). dass,das,5,
(d). dass,das,%x,
(e). 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). error : Invalid indirection
(b). garbage value
(c). 1,b
(d). 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). 17,8
(b). 17,9
(c). 18,8
(d). 18,9
(e). 19,8
(f). 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). infinite loop
(b). error
(c). -1,-1,1
(d). 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). hai
(b). bye
(c). junk values
(d). 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). 1
(b). 0
(c). error
(d). 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). 13,-5
(b). 14,-5
(c). -5,-5
(d). - 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). 13,1,1
(b). 13,0,0
(c). 13,1,0
(d). 13,0,1
(e). error
73. What is the output of the following program?
main()
{
char name[]={"hai"};
clrscr();
printf("%s",name[0]);
return 0;
}
(a). hai
(b). junk values
(c). error
(d). 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). h,h,hai,hai friends
(b). infinite loop
(c). garbage value
(d). 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). hai,hai,hai,hai,hai,hai,hai,hai,daylight
(b). hai,hai,hai,hai,hai,hai,hai,daylight
(c). hai,hai,hai,hai,hai,hai,daylight
(d). 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). 2,1,1,1,2,2,
(b). 2,2,2,1,2,2,
(c). 2,1,2,1,2,2,
(d). 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). 16
(b). 15
(c). 14
(d). 13
(e). 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). 5,6,7,12
(b). 5,6,7,11
(c). 4,5,7,12
(d). 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). 16,0
(b). 15,0
(c). 1,1
(d). 0,0
(e). 1,0
(f). 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). 0
(b). 1
(c). 2
(d). 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). a=1,b=1
(b). a=1,b=0
(c). a=0,b=0
(d). 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). 4321
(b). 3210
(c). 321
(d). 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). a,2
(b). a,1
(c). b,1
(d). b,2
(e). 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). 12345
(b). abcde
(c). a2345
(d). 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). infinite loop
(b). i=5
(c). i=5i=5i=5
(d). i=5i=5i=5i=5
(e). 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). 200
(b). 2000
(c). 4000
(d). 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). illegal initialization
(b). garbage values
(c). error in printf statement
(d). 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). c=9a,i=9b
(b). c=0x99,i=99
(c). c=0x99,i=0x99
(d). error
(e). 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). 3
(b). 6
(c). 1
(d). 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). 6
(b). 2
(c). 10
(d). 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). 2,2
(b). 1,2
(c). 16,2
(d). 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). age = junkvalue
(b). age = hownice?
(c). age = h
(d). 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). 1,0
(b). 0,1
(c). error
(d). 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). include is not allowed inside main()
(b). excellent clear
(c). garbage value
(d). 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). include is not allowed inside main()
(b). Illegal declaration of *_
(c). garbage value
(d). typical program