Tuesday, July 7, 2009

C programming TECHNICAL MCQ Exercise -15

Q. 1 . Find the output.
void main()
{
int x[5];
see(x);
printf("%d",x[2]);
}
see(int x[])
{
x++;
x[1]=100;
}
a . 100
b . 0
c . Garbage
d . None of these

Q. 2 . Which storage class can precede any data type in the parameter list?
a . Auto
b . Static
c . Register
d . Extern
Q. 3 . ftell()
a . Takes only one argument
b . Takes two arguments
c . Moves the file pointer only in forward direction
d . None of these
Q. 4 . The operators [],.,-> are known as
a . Data access operators
b . Structure access operators
c . Member access operators
d . None of these
Q. 5 . What is not possible with union?
a . Array of union
b . Pointer to union
c . Self-referential union
d . None of these
Q. 6 . Find out the output
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);
}
a . Compilation will only give a warning but will proceed to execute & will
display "fast"
b . Display "fast" on screen
c . Error illegal initialization
d . None of the above
Q. 7 . Find the correct output
void main()
{
struct dist
{
char *c;
int i;
struct dist *d;
};
static struct dist arr[]={{"Raipur",1,arr+1},
{"Kolapur",2,arr+2},
{"Bhabanipur",3,arr}
};
struct dist *dis=arr;
printf("%s",arr[(++dis)->i].c);
}
a . Kolapur
b . Raipur
c . Bhabanipur
d . aipur
Q. 8 . Find the output
void main()
{
enum color{red, green};
enum colors{green,white};
printf("%d %d",green, white);
}
a . 1 1
b . 0 1
c . 1 0
d . None of these
Q. 9 . The function unlink(filename) is used
a . to remove link between file and buffer
b . to remove the existing file from the directory
c . to remove the contents of file only
d . None of these
Q. 10 . Find the output
void main()
{
int i=5;
for(i=-5; !!i; i++);
printf("%d",-i)
}
a . 5
b . 0
c . -5
d . None of these
Q. 11 . Find the output
void main()
{
int x=1;
do{
printf(‘a’);
x++;
}while(x<5); x="65535;x">=1;x++)
printf("no output");
}
a . no output
b . Prints no output infinite times
c . No output
d . None of these
Q. 15 . Find out the output.
void main()
{
int val=2;
val = - --val- val-- - --val;
printf("%d",val);
}
a . Compile time Error
b . 3
c . -1
d . 0

Q. 13 . Find out the output
main()
{
int i=-3,j=2,k=0,m;
m=++i&&++j++k;
printf("\n %d %d %d %d",i,j,k,m);
}
a . -2 3 0 1
b . -3 2 0 1
c . -2 3 1 1
d . Error
Q. 14 . Find the correct output
void main()
{
int *p,*q,*r;
q=(int *)malloc(sizeof(int));
p=q-1;
r=q+1;
*p=100;
*q=200;
*r=300;
p++;
q++;
printf("%d %d",*p,*q);
}
a . 10 20
b . 20 20
c . 20 30
d . 30 30
Q. 15 . Find the correct output
struct byte
{
int a:2;
int b:1;
int c;
};
void main()
{
struct byte d;
printf("%d",sizeof(d));
printf("%d",sizeof(d.a));
}
a . 4 1
b . 3 1
c . Error
d . None of these
Q. 16 . Find out the output
void main()
{
printf("\/\*\-*\/");
}
a . Run time Error
b . \/*-*\/
c . /*-*/
d . None of these
Q. 17 . Find the output.
void main()
{
char ch=’\356’;
printf("%d",ch);
}
a . -18
b . 18
c . Error
d . 51
Q. 18 . Find the correct output
void main()
{
char *p="CITE";
char *q;
q=(char *)malloc(sizeof(p));
while(*p++=*q++);
printf("%s",q);
}
a . CITE
b . ITE
c . Empty string
d . None of these
Q. 19 . During linking the linker adds more information in the header of the executable file, known as
a . link parameter
b . load parameter
c . program segment prefix
d . dynamic link library
Q. 20 . Character constant is 2 byte long to represent
a . hexadecimal constant
b . octal constant
c . both octal & hexadecimal constant
d . none of these
Q. 21 . Find the correct output
void main()
{
int x;
x=compute(4);
printf("%d",x);
}
int compute(int n)
{
if(n<=1) return 2; 
else 
return(compute(n-2)*compute(n-1)); 
} a . 10 b . 8 c . 16 d . 32
 Q. 22 . Find the correct output 
#include"string.h" 
#include"alloc.h" 
void main()
 { 
struct linklist 
int item;
 struct node *link; 
}; 
struct linklist *p,*q; 
p=(struct linklist *)malloc(sizeof(struct linklist)); 
q=(struct linklist *)malloc(sizeof(struct linklist));
 p-> item=10;
q-> item=20;
p-> link=q;
q-> link=p;
while(p)
{
printf("%d",p->item);
p=p->link;
}
}
a . 101010……….
b . 10201020……..
c . 202020………..
d . None of these
Q. 23 . Unary operators are
a . Operator dependant
b . Position dependant
c . Value dependant
d . Both b and c.
Q. 24 . Find out the output.
void main()
{
char c=65;
c=(!=c);
printf("%d",c);
}
a . 0
b . 65
c . 1
d . 66
Q. 25 . The secret signature of Borland International (in Turbo C 3.0) is kept in
a . data area
b . code area
c . text area
d . none of these
Q. 26 . Stack is useful for implementing
a . Recursion
b . Breadth first search
c . Both a and b
d . None of these
Q. 27 . State the true statement.
‘void ‘ is an empty data type associated with
a . all aggregate types
b . all data types
c . all functions and pointers
d . all the above
Q. 28 . Find out the output
void main()
{
char *s[]={"utpal","bubu"};
printf("%c %s",*name[0],name[1]);
}
a . u bubu
b . u garbage
c . garbage bubu
d . None of these
Q. 29 . Find the correct output
void main()
{
int i=5;
enum vehicle{car=i,bike,scooter};
printf("%d",car);
}
a . 0
b . 5
c . Error
d . None of these
Q. 30 . A unit of 8 bits is known as byte in same way a unit of 4 bits is known
a . half byte
b . ribble
c . nibble
d . none of these

No comments:

Blog List