Tuesday, July 7, 2009

C programming TECHNICAL MCQ Exercise -11

Q. 1 . Find the output
void main()
{
int i=4,j=-3;
mul(&i,j);
printf("%d %d",i,j);
}
mul(int *a,int b)
{
a=*a**a;
b=b*b;
}
a . 4 3
b . 4 9
c . 16 -3
d . 16 9
Q. 2 . Find the output.
void main()
{
unsigned long i=40000;
printf("%l", i);
}
a . %l
b . 40000
c . Garbage
d . No output
Q. 3 . Find out the output
void main()
{
static int x=4,y=5;
callme(x,y);
}
callme(static int x,static int y)
{
x=y;
y=x;
printf("%d %d",x,y);
}
a . 4 5
b . 5 5
c . Error
d . None of these
Q. 4 . State the correct statement.
a . Nested union is not possible.
b . Self referential union is possible
c . Different interpretations for the same memory location are possible in structure.
d . Both a and c
Q. 5 . Find out the output
void main()
{
printf("%d",(4,7,11)-(6,5,12));
}
a . 5
b . -2
c . -1
d . None of these
Q. 6 . Find out the output
void main()
{
int i=0;
((i--,++i)!=0);
i-=i++;
i+=i++;
printf("i=%d",i);
}
a . 3
b . 2
c . 1
d . Error
Q. 7 . The default initial value of malloc() memory allocation is
a . Garbage
b . Zero
c . Can’t say
d . None of these
Q. 8 . Which of the file extensions is used as executable file?
a . .EXE
b . .COM
c . .BAT
d . all the above
Q. 9 . Find the output
#define ABC(x) printf("%d",x);\
printf("%0",x);
void main()
{
int x=12;
ABC(x)
}
a . 1214
b . 1212
c . 12
d . Error
Q. 10 . Find the output.
void main()
{
int array[]={1,3,5,7,9},*p,i;
p=array[0];
for(i=0;i<5;i++) a="15;" date="{&a," p="&date;">p);
10. }
a . Line no.8
b . Line no. 9
c . Line no.6
d . None
Q. 12 . Find the correct output
void main()
{
int a=2,b=5;
if(a,b,0)
printf("Norton");
else
printf("Avast");
}
a . Norton
b . Avast
c . Compilation error
d . None of these
Q. 13 . Find the output
void main()
{
while(!"")
{
printf("Hello");
}
}
a . Prints Hello infinite times
b . Hello
c . Error
d . No output
Q. 14 . Find out the output
void main()
{
char a[]="abcde";
char *p=a;
p++;
p++;
p[2]='z';
printf("%s",p);
}
a . zde
b . cdz
c . abzde
d . abz
Q. 15 . Find the correct output
void main()
{
char a[][9]={"Lakshya","Advance","C","Training","Java"};
printf("%c %s in %s",a[2][0],&a[3][0],&a[0][0]);
}
a . CT in L
b . C in Lakshya
c . C Training in Lakshya
d . Error
Q. 16 . The pointer which is created in data segment and holds the address of base location is known as
a . Near pointer
b . Bad pointer
c . Smart pointer
d . None of these
Q. 17 . State the correct statement.
a . A for loop may be nested in a while loop.
b . A do-while loop may be nested in a for loop
c . A while loop may be nested in a for loop
d . All the above
Q. 18 . Find out the output
void main()
{
int a=1,b=2,c=3;
scanf("%d %*d %d",&a,&b,&c);
printf("a=%d b=%d c=%d",a,b,c);
}
[ NOTE : 3 values entered by the user are:100 200 300 ]
a . a=1 b=2 c=3
b . a=100 b=200 c=300
c . a=100 b=200 c=3
d . a=100 b=300 c=3
Q. 19 . What is the format specifier of long double?
a . %ld
b . %id
c . %lf
d . %g
Q. 20 . What is the format specifier of long double?
a . %ld
b . %id
c . %lf
d . %g
Q. 21 . Find the correct output
void main()
{
int i=1;
i=(5>2)?printf(""Rama):printf("Shyama");
printf("%d",i);
}
a . Rama1
b . Rama4
c . Rama0
d . None of these
Q. 22 . int far **p, here p is a
a . Far pointer holds address of another far pointer.
b . Near pointer holds address of another far pointer.
c . Far pointer holds address of another near pointer.
d . Near pointer holds address of another near pointer.
Q. 23 . Find out the output
void main()
{
int i;
char *p="lakshya",c;
while(i++printf?"cool":"fool");
}
a . cool
b . fool
c . No output
d . None of these
Q. 30 . Find the correct output
void main()
{
int a=0;
for(a;++a;a<=100) printf("%d",a); 
a . Print 1 to 99 infinite times b . Print 1 to 99 
c . Print some garbage values d . Infinite loop


No comments:

Blog List