Tuesday, July 7, 2009

C programming TECHNICAL MCQ Exercise -7

Q.1 Output?

#define PRINT(x1,x2) PR(x1); PR(x2); NULL
void main()
{
int x=5,y=10;
PRINT(x,y);
}
a . 5 10 error
b . 10 5 error
c . 5 10
d . 10 5
Q. 12 . Find the output
#define MAX(x,y) x>y?x:y
void main()
{
int x=2,y=3;
printf("%d",MAX(++x,++y));
}
a . 4
b . 5
c . Error
d . None of these
Q. 13 . Find out the output
void main()
{
unsigned int a=65536;
if(!a)
printf("%d",a,++a);
else
printf("%d",a,++a);
}
a . 0
b . 1
c . 65536
d . 65537
Q. 14 . x%y is equal to
a . y-(x/y)*x
b . x-(x/y)*y
c . x-(y/x)*x
d . y-(y/x)*y
Q. 15 . #define dprintf(e) printf(#e " = %d\n",'e')
void main()
{
int x=8;
int y=3;
dprintf(x/y);
}
a . expr=2
b . expr=101
c . x/y=101
d . None of the Above.
Q. 16 . Find out the output
void main()
{
int x=6,y=4,z=0;
if((x>=y)(z=y))
z-=2;
printf("%d",z);
}
a . 0
b . 2
c . -2
d . None of these
Q. 17 . Self referential structure
a . Used to create a memory link.
b . Plays an important role in linked list creation.
c . Contains the object of same structure which is of pointer type.
d . All the above
Q. 18 . Find out the output
typedef struct boy
{
float height;
char name:9;
int age:16;
}boy;
void main()
{
boy b={5.8,"Praveen kumar",24};
printf("%f %s %d",b.height,b.name,b.age);
}
a . 5.8 Praveen k 24
b . 5.8 Praveen kumar 24
c . 5.8 Praveen k 16
d . None of these
Q. 19 . Switch-case statement does not implement on
a . non exclusive case
b . mutually exclusive case
c . mutually non exclusive case
d . exclusive case
Q. 20 . Find out the output
void main()
{
unsigned int i=2;
i=(((i<<6)-1)^127); i="15;">y? x:y
void main()
{
int a,b;
a=MAX(1,2)+3;
b=MAX(4,3)+5;
printf("%d %d",a,b);
}
a . 5 4
b . 5 9
c . 5 8
d . None of these
Q. 24 . Find the output
void main()
{
*(char*)65=’a’;
printf ("%c",*(char*)65);
}
a . a
b . A
c . Error
d . None of these
Q. 25 . The function ftell(fp) returns
a . The beginning position of the file represented by fp.
b . The end position of the file represented by fp.
c . The current position of the file represented by fp.
d . None of these
Q. 26 . 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. 27 . Find the correct output
void main()
{
char a[4]="rama";
char b[]="shyama";
printf("%d %d", sizeof(a),sizeof( b)) ;
}
a . 4 7
b . 5 6
c . 5 7
d . 4 6
Q. 28 . Find the correct output
typedef struct tag
{
int i;
char c;
}tag;
void main()
{
struct tag t1={1,’C’};
tag t2={2,’A’};
printf("%d%c ",t1.i,t1.c);
printf("%d%c ",t2.i,t2.c);
}
a . Error in first printf() statement.
b . Error in second printf() statement.
c . 1C 2A
d . None of these
Q. 29 . Find the correct output
void main()
{
int i=5;
i=++i + ++i + i++;
printf("%d",i);
}
a . 21
b . 22
c . 19
d . None of these
Q. 30 . What will be the value of ‘x’ after execution of the following program?
void main()
{
int x=!0*20;
}
a . 10
b . 20
c . 1
d . 0

No comments:

Blog List