PREVIOUS NEXT
C
INTERVIEW QUESTIONS WITH ANSWERS
1
#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", MON, TUE,
WED, THU, FRI, SAT);
return 0;
}
|
||||||||||
Answer: Option D
|
enum
days={MON=-1,TUE,WED=6,THU,FRI,SAT}
so the value for monday = -1;
usually enum ill take the values sequentially, dats if enum month={a=0,b};
her the value for b=1(dats next of 1)
like wise the value for TUE=0;
den wed=6(ITS ALREADY GIVEN),therefore next value s 7 hence THU=7,DEN FRI=8,SAT=9
so the value for monday = -1;
usually enum ill take the values sequentially, dats if enum month={a=0,b};
her the value for b=1(dats next of 1)
like wise the value for TUE=0;
den wed=6(ITS ALREADY GIVEN),therefore next value s 7 hence THU=7,DEN FRI=8,SAT=9
2
#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", ++MON, TUE,
WED, THU, FRI, SAT);
return 0;
}
Because union
can initialize only one variable at a time. It overwrites the memory with
binary value of 20 where it was initialized with binary value of 10 before.
It takes the last initialized value of its member variables.
As we know that
truth table of AND is if 2 number is true then only output becomes true. For
that reason & is used to find bits on or off.
Here each *
means address holding it i.e. 'p' holds address of 'i', *p value at i = 8.
'q' holds address of p, p holds address of 'i'. So with two ** we are back to value at i = 8. Similarly, three times *** means jump from r to q to p that holds i = 8.
Because we
can't print % in C.
To print % we need %% in C for printing single %. Hence to print %% we need %%%%
ASCII Value of
'C' is 67.
67*-1=-67 applying bitwise not(~) to -67 will result in 66, which is the ASCII value of 'B'. |
No comments:
Post a Comment