C Aptitude Questions and Answers(Part-2)
Predict the output or error(s) for the following: 36. main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here } Answer: 1 Explanation: Scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1. 37. #define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); } Answer: 100 38. main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); } Answer: 1 Explanation: before entering into the for loop the checking condition is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop). 39. ...