Output of C programs | Set 46
QUE.1 What would be output following C program?
Explanation : & is a reference operator, * is de-reference operator. We can use these operators any number of times. str points the first character of IncludeHelp, *str points “I”, * & again reference and de-reference the value of str.
QUE.2 What would be output following C program?
b) value =50, size= 4
value =65, size= 4
c) value =50, size= 4
value =65, size= 1
Explanation : void pointer can be type casted to any type of data type, and pointer takes 4 bytes (On 32 bit compiler). To print value using void pointer, you will have to write like this *(data_type*)void_ptr;.
QUE.3 What would be output following C program?
a) 11, 11
b) 10, 11
d) 10, 10
Explanation : *(char*)ptr will return the value of ch, since we know printf evaluates right to left. So, ++(*(char*)ptr) will increase the value to 11.
QUE.4 What is the output of the following C program?
d) None of these
Explanation : ERROR: unexpected end of file found in comment. The compiler is treated the operator / and * as /*, that happens to be the starting of comment. To fix the error, use either *pa/ *pb (space between operators) or *pa/(*pb).
QUE.5 What is the output of the following C program?
a) c= 12
b) c= 10
c) c= 2
d) c= 0
Explanation : Bitwise AND (&) operator copies bit(s), if they are exist both of the operands. Here, binary of a is “1010” and binary of b is “0010”. Thus, result of expression (a & b) is “0010” which is equivalent to 2 in Decimal.
This article is contributed by Ajay Puri(ajay0007). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.