VOOZH about

URL: https://www.geeksforgeeks.org/c/output-of-c-programs-set-46/

⇱ Output of C programs | Set 46 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 46

Last Updated : 19 Oct, 2022
QUE.1 What would be output following C program? OPTION a) Error b) IncludeHelp c) I d)*I
 Answer: c
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? OPTION a) Error b) value =50, size= 4 value =65, size= 4 c) value =50, size= 4 value =65, size= 1 d)Garbage Values
Answer: b
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? OPTION a) 11, 11 b) 10, 11 c) ERROR d) 10, 10
Answer: a
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? OPTION a) 5 b) 5.0 c) ERROR d) None of these
Answer:c
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?
OPTION a) c= 12 b) c= 10 c) c= 2 d) c= 0
Answer:c
Explanation : Bitwise AND (&) operator copies bit(s), if there 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.
Comment
Article Tags: