Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
4
3
2
error
(a).
(b).
(c).
(d).
(e).
error
%p,%p,%p,%p
1,-1,2,0
junk values
0001,FFFF,0002,0000
syntax error
3
sorry
runtime dependent
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
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
,s2,1,JIKA,
,s2,1,JIKA,4,
JIKA,4,s2,1
JIKA,,s,1
error
(a).
(b).
(c).
(d).
(e).
onetwothreefour
onetwothree
threefour
onetwofour
twothreefour
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
(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
else
printf("NOT EQUAL");
getch( );
}
(a).
(b).
(c).
(d).
NOT EQUAL
EQUAL
compiles and no answer
compiles but don't run
craft
craf
Lvalue required
raft
(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
(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
0,100,
error
0,0,0,0,...
0,100,200,300,...
(a).
(b).
(c).
(d).
13,8,14,-6
13,8,13,-6
error
depends on the address of the buffer
3
6
2
error
5,8
8,5
error (no return statement in swap())
junk values
printf("%d",buffer[ptr++]);
getch();
}
(a).
(b).
(c).
(d).
9,9,9
9,junk,9
0x9,junk,9
9,junk,8
compiler dependent
garbage value
values depend upon the fox address
error (invalid pointer addition)
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
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
RD D RD
value Ascii value %(-2.6+1)c Ascii value Ascii
LI RD
LI LI
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
#include <stdio.h>
void main()
{
char *s="hai";
clrscr();
printf("%.*,%s",s,s);
getch();
}
(a).
(b).
(c).
(d).
%.*,hai
%.*,%s
.*,hai
error
5
will not compile
empty screen
garbage value
#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
0,65535,65534,...
empty screen
0,65535,65533,...
0,65534,65532,...
0,garbage values...
bate=&bat[5];
printf("%d",bate[-1]);
getch();
}
(a).
(b).
(c).
(d).
(e).
(f).
(g).
5
4
3
2
1
error
garbage value
46.
#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
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
buddy is good
dummy is good
possibly incorrect assignment
error
#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
returns
1 2 3 4
error
5 4 3 2
0 1 2 3
nothing
5
1
4 5
clrscr();
t=malloc(strlen(p)+1);
strcpy(t,n);
printf("%s",t);
getch();
}
(a).
(b).
(c).
(d).
(e).
stu
stum
stump
stumped
error
1,4
2,4
1,3
2,3
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
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
(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
(b).
(c).
(d).
(e).
397,-198
397,596
3977,596
397,198
dass,das,5,4
dass,das,4,3
dass,das,5,
dass,das,%x,
error
(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
infinite loop
error
-1,-1,1
1,1,1
(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
1
0
error
empty screen
return 0;
}
(a).
(b).
(c).
(d).
13,-5
14,-5
-5,-5
- 5,-5
13,1,1
13,0,0
13,1,0
13,0,1
error
hai
junk values
error
h
(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
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
}
(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
16
15
14
13
12
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
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
0
1
2
3
a=1,b=1
a=1,b=0
a=0,b=0
error
int x=3;
clrscr();
while(x--);
{
int x=4;
x--;
printf("%d",x);
}
return 0;
}
(a).
(b).
(c).
(d).
4321
3210
321
3
a,2
a,1
b,1
b,2
error
12345
abcde
a2345
error
infinite loop
i=5
i=5i=5i=5
i=5i=5i=5i=5
error
200
2000
4000
error: Illegal use of pointers
(d).
leaders
illegal initialization
garbage values
error in printf statement
empty screen
c=9a,i=9b
c=0x99,i=99
c=0x99,i=0x99
error
c=0x99,a=garbage value
int result;
clrscr();
result = foo(7);
printf("%d",result);
return 0;
}
(a).
(b).
(c).
(d).
3
6
1
0
6
2
10
0
}
(a).
(b).
(c).
(d).
2,2
1,2
16,2
4,2
age = junkvalue
age = hownice?
age = h
error
1,0
0,1
error
junk values
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