Tuesday, July 7, 2009

MCQ of C programming Exercise -6

Q. 1 . How many times the loop will be executed?
void main() {
char c;
for(c=1;c<=127;c++) printf("Lakshya"); } a . 127 times b . 126 times c . Only once d . None of these Q. 2 . Find the correct output void main() { i nt a[]={1,2,3,4,5}; int *p=(int *)(&a+1); printf("%d %d",*(a+1),*(p-1)); } a . 2 0 b . 1 0 c . 2 5 d . 1 garbage

Q. 3 . Find the output
void main() {
char *p="hello";
printf ("%.3s", p);
}
a . hel b . llo c . 3hello d . None of these
Q. 4 . put these stages of compilation in order,
a) link
b) compilation
c) execute
d) Precompilation
a . a,b,c,d b . d,b,a,c c . d,c,b,a d . a,c,b,d

Q. 5 . Find the correct output
void main() {
struct node {
int data;
struct node *link;
};
struct node *p,*q;
p=malloc(sizeof(struct node));
q=malloc(sizeof(struct node));
printf("%d %d",sizeof(p),sizeof(q));
}
a . 4 4 b . 2 2 c . 1 1 d . None of these

Q. 6 . Size of the physical address of 80x86 microprocessor is
a . 16 bits b . 20 bits c . 24 bits d . 32 bits
Q. 7 . Find the output
void main() {
int x=2,y=3,z; z=x++y++&&x++;
printf("%d %d %d",x,y,z);
}
a . 3 3 1 b . 4 4 1 c . 4 3 1 d . None of these
Q. 8 . Find the correct output
void main () {
for(clrscr();printf ("CITE");getch())
{} }
a . Print CITE infinite times
b . Print CITE for one time
c . Print CITE as long as long as a keyboard is hit
d . Print CITE for one time then print some garbage values.

Q. 9 . Find out the output
void paws(int *apple,int *ball)
{
*apple=*apple+*ball;
*ball=*apple-*ball;
*apple=*apple-*ball;
}
void main()
{
int apple=3617283450;
int ball=3617283449;
paws(&apple,&ball);
printf("%d %d",apple,ball);
}
a . 23929 23930 b . 23322 23323 c . 23939 23940 d . Error

Q. 10 . What happens when far address is incremented?
a . Only segment address is incremented.
b . Only offset address is incremented.
c . Both segment and offset address are incremented.
d . None of these
Q. 11 . Find out the output
void main() {
char *p="rama"; char *q=0;
char *r="\bsita";
strcpy(q,p);
strcat(q,r);
printf("%s",q); }
a . ramsita b . ramasita c . rama\sita d . None of these
Q. 12 . Find the output.
void main() {
int a=4,b=5;
printit(a, b);
}
printit(int b, int a) {
printf("%d %d", a, b);
{
int a=0; int b=1;
printf("%d %d", a, b);
} }
a . 4 5 0 1 b . 5 4 0 1 c . 5 4 5 4 d . None of these

Q. 13 . Find out the output.
void main()
{
int a=5,b=7;
int *p; p=&a; p--;
*p=10; printf("%d %d",a,b);
}
a . 5 7 b . 5 10 c . 10 7 d . Garbage 7

Q. 14 . The address of all ISR is kept in
a . IVT
b . Page table
c . Segmentation table
d . None of these

Q. 15 . Find the output.
void main() {
int x=5,y=6;
do{
x=x+y;
y=x-y;
x=x-y;
}while(x=0)
j++;
}
a . 5 times
b . 6 times
c . Infinite times
d . None of these
Q. 30 . Find out the output
void main()
{
printf("%u",main);
}
a . Garbage value
b . Run time error
c . Printing starting address of function main
d . Infinite loop

No comments:

Blog List