1 What is the Output
of the following code
main()
{
char
*str = "12345";
printf("%c
%c %c\n", *str, *(str++), *(str++));
}
2.
What is the Output of the following code
main()
{
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d
\n",u.a,u.b);
}
3.What
is the Output of the following code
main()
{
printf("Hello
%d",printf("QUARK test?"));
}
(a).
Compile time error. ( b). Hello
QUARK test? (c). Run time error.
(d).
Quark Test ?Hello. (e). None of
the above.
4.
What shall be the output of the following code?
main()
{
int
i,j;
printf(“QUARK
%s\n”,main());
}
a.
Compilation error. b.
Run-time error
c.
Continuous scrolling Quark on the screen.
d. None of the above.
5.
What is Output of the following code
int
count(int i)
{
if
( i < 0) return(i);
else
return( count(i-2) + count(i-1));
}
main()
{
int
j,ans;
j
= 4;
ans
= count(4);
printf("%d\n",ans);
}
6.
Is there any Error in the following code :
main()
{
extern int i;
if(i=0)
printf("statement 1");
else
printf("statement
2");
}
int
i =4;
7. Out put of the following code is
main()
{
int
i,j,A;
for
(A = -1;A<=1; A++)
printf("%d\t",!!A);
}
8. What will be the result of the following
code?
int
*x;
x
=(int *) 15;
a.
Compilation error b.
Compiles but gives a runtime error
c.
Absolute location 15 in the memory space shall be assigned to pointer x;
d.
Location 15 in the program space is assigned to pointer x;
e.
Location 15 contains the address to an integer.
9.
What will be the O/P of following code :
#define
f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a.
8 b. 64 c. 10 d. 12
10.
What will be the O/P of following code :
main()
{
void
fun1(void *);
char
a[] = "quark";
void
*temp;
temp
= a;
fun1(temp);
}
void
fun1(void *temp1 )
{
int
t1 = 0;
while(*((char*)temp1+
t1++ )!='\0') {
printf("%c",*((char*)temp1
+ t1));
}
}
a.
Compilation error b. ark c. quark d. uark
11. What will be the O/P of following code :
void
main()
{
int
x= -5;
printf("%d\t
%d",x>>1, x<<3);
}
12. What will be the O/P of following code :
int
* func(){
static
int x=0;
x++;
return &x;
}
int
main()
{
int
* y = func();
printf("%d",(*y)++);
func();
printf("%d\n",*y);
return
0;
}
a.
Compilation error. b. Prints 1 and 3
c.
Prints 1 and 2 d.
Prints 1 and 1
13.
What will be the O/P of following code :
void
main()
{
unsigned
int x = -1;
int
y =0;
if(y<=x)
printf("A is true\n");
if
(y ==(x = -10)) printf("B is
true\n");
if
((int) x>=y) printf("C is
true\n");
}
a.
A is true. b.
B is true.
c.
C is true. d.
None of the above.
14. In the following code what is the correct way
to increment the variable ptr to
point
to the next member of the array
union
intfloat
{
int
intArray[ 5];
float
floatArray[ 5];
};
union
intfloat arr[20];
void
*ptr =arr;
a.
++(int*)ptr; b. ptr = ptr+5; c. ptr = ptr +sizeof(*ptr);
d.
ptr = ptr+sizeof(intfloat.floatArray); e.
ptr = (void*)((union intfloat*)ptr +1);
15.
What will be the O/P of following code :
#define
PRINTXYZ(x,y,z) printf (#x "=%d\t" #z "=%d\n", x, y)
void
main() {
int
x, y, z;
x=0;
y=1; z=2;
x
|| ++y ||++z;
PRINTXYZ(x,y,z);
++x
|| ++y && ++z;
PRINTXYZ(x,y,z);
++x
&& ++y || ++z;
PRINTXYZ(x,y,z);
}
a.
Compilation error. b.
Runtime error.
c. x=0 z=2 d.
x=0 z=2
x=1
z=3 x=1 z=2
x=2
z=4 x=2 z=3
0 comments:
Post a Comment