Tuesday, July 7, 2009

C programming TECHNICAL MCQ Exercise -3


Q. 1 . Find the correct output
#include"string.h"
void main()
{
struct node
{
int data;
struct node *next;
};
struct node *p,*q;
p=(struct node *)malloc(sizeof(struct node));
q=(struct node *)malloc(sizeof(struct node));
p->data=10;
q->data=20;
p->next=q;
q->next=NULL;
printf("%d",p->data);
p=p->next;
printf("%d",p->data);
}
a . 10 20
b . 10 Garbage value
c . 20 Garbage value
d . None of these


Q. 2 . Find out the output
void main()
{
int x=2,*y=&x;
printf("%d",x*y);
}
a . 4
b . Garbage
c . Prints result of multiplication of address of x and x
d . Error

Q. 3 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()

Q. 4 . Find out the output
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a . 20
b . Garbage value
c . Error
d . 0

Q. 5 . Which format specifier is used to find out the offset address of a variable?
a . %o
b . %p
c . %h
d . %d

Q. 6 . Find out the output.
#define fool !1 - -1
void main()
{
printf("Hi!");
if (fool)
printf("Bye");
}
a . Lvalue required
b . Hi!
c . Bye
d . Hi!Bye

Q. 7 . Find out the output
void main()
{
char str[20];
static int i;
for(;;)
{
i++[str]= 'a'+15;
if(i==19)
break;
i++;
}
i[str]='\0';
printf("%s",str);
}
a . Error
b . Garbage value
c . p
d . pppppppppppppppppppp

Q. 8 . When loop looses its stop value then it is called
I. Odd loop
II. Even loop
III. Unknown loop
IV. User friendly loop
a . only I
b . I & III
c . III & IV
d . II & IV

Q. 9 . Find the correct output
void main()
{
int x=10,y=20,p,q;
p=add(x,y);
q=add(x,y);
printf("%d %d",p,q);
}
add(int a,int b)
{
a+=a;
b+=b;
return(a);
return(b);
}
a . 10 10
b . 20 20
c . 10 20
d . 20 10

Q. 10 . Find out the output
main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d" ,*(a+1),*(ptr-1));
}
a . 2 2
b . 2 1
c . 2 5
d . None of the above

Q. 11 . The area or scope of the variable depends on its
a . Date type
b . Storage class
c . System type
d . None of these

Q. 12 . Each case statement in switch is separated by
a . break
b . continue
c . exit()
d . goto

Q. 13 . Find out the output
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a . 20
b . Garbage value
c . Error
d . 0

Q. 14 . Find out the output
void main()
{
int a[5]={1,2,3};
int j;
for(j=0;j<5;j++) 
x1="5.74,x2="23.78;" x1="5.74" x2="23.78" 
opname =" Xstr(OP);" p="c;" p="lakshya" x="10;" x="callme(x);" i="5;" x="x/2-3;" s="’\dx’;" i="2;">>1)
{
default: i++;
case 1: ;
case 2: ;
}
printf("%d",i);
}
a . 2
b . 1
c . Expression syntax error
d . None of these

Q. 29 . Find the correct output
void main()
{
int a,b,c;
c=scanf("%d%d",&a,&b);
printf("\n%d",c);
}
a . 1
b . 2
c . 0
d . None of these
Q. 30 . Which of the following is known as auxillary memory?
a . RAM
b . ROM
c . HARD DISK
d . BIOS

No comments:

Blog List