Step 1: x=y=z=1; here the variables x ,y, z are initialized to value '1'.
Step 2: z = ++x || ++y && ++z; becomes z = ( (++x) || (++y && ++z) ). Here ++x becomes 2. So there is no need to check the other side because ||(Logical OR) condition is satisfied.(z = (2 || ++y && ++z)). There is no need to process ++y && ++z. Hence it returns '1'. So the value of variable z is '1'
Step 3: printf("x=%d, y=%d, z=%d
", x, y, z); It prints "x=2, y=1, z=1". here x is increemented in previous step. y and z are not increemented.
Q. No. :
4
Question :
What is the output of the following program segment?
void max(int x, int y, int m)
{ if(x>5) m=x;
else m=y;}
int main()
{
int i=20, j=5, k=0;
max(i,j,k);
printf("%d",k);
}
While calling the function myFunc address of array is passed and it is incremented by 3. Hence Now the address is pointing to L and print onwards ie LLO
Q. No. :
9
Question :
What number will z in the sample code below contain?
int i = 4;
switch (i)
{
default:
;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d
", i);
The struct emp is mentioned in the prototype of the function modify() before declaring the structure.To solve this problem declare struct emp before the modify() prototype.
Q. No. :
15
Question :
What will be the output of the code snippet if compiler is considered to be 32 bit?
struct ptr
{
int a;
char b;
int *p;
union xy
{
int x;
char y;
};
}abc;
printf("%d",sizeof(abc));
A :
5
B :
7
C :
8
D :
10
Answer: B
Q. No. :
16
Question :
Which one of the following functions is the correct choice for moving blocks of binary data that are of arbitrary size and position in memory?
The macro function SQR(x)(x*x) calculate the square of the given number 'x'. (Eg: 102) Step 1: int a, b=3; Here the variable a, b are declared as an integer type and the variable b is initialized to 3. Step 2: a = SQR(b+2); becomes, => a = b+2 * b+2; Here SQR(x) is replaced by macro to x*x . => a = 3+2 * 3+2; => a = 3 + 6 + 2; => a = 11; Step 3: printf("%d
", a); It prints the value of variable 'a'. Hence the output of the program is 11
Q. No. :
23
Question :
What will be the output of the program?
#include< stdio.h >
int sumdig(int);
int main()
{
int a, b;
a = sumdig(123);
b = sumdig(123);
printf("%d, %d
", a, b);
return 0;
}
int sumdig(int n)
{
int s, d;
if(n!=0)
{
d = n%10;
n = n/10;
s = d+sumdig(n);
}
else
return 0;
return s;
}
A :
4,4
B :
3,3
C :
6,6
D :
12,12
Answer: C
Q. No. :
24
Question :
What does the "auto" specifier do?
A :
It automatically initializes a variable to 0;
B :
It indicates that a variable's memory will automatically be preserved.
C :
It automatically increments the variable when used.
D :
It automatically initializes a variable to NULL.
Answer: B
Q. No. :
25
Question :
Assume integer is 2 bytes wide. How many bytes will be allocated for the following code?
int main()
{
int (*p)[MAXCOL];
p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
return 0;
}
A :
56 bytes
B :
128 bytes
C :
24 bytes
D :
12 bytes
Answer: C
Q. No. :
26
Question :
int a [8] = { 0, 1, 2, 3 };
The definition of a above explicitly initializes its first four elements. Which one of the following describes how the compiler treats the remaining four elements?
A :
Standard C defines this particular behavior as implementation-dependent. The compiler writer has the freedom to decide how the remaining elements will be handled.
B :
The remaining elements are initialized to zero(0)
C :
It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized
D :
As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively.
Answer: B
Q. No. :
27
Question :
Assuming a short is two bytes long, what will be printed by the above code?