C Aptitude Questions and answers with explanation

C Aptitude 13





Predict the output or error(s) for the following:

C aptitude 13.1

int i=0;


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).

C aptitude 13.2

char *p,*str,*str1;

Answer: M

Explanation:p is pointing to character ‘n’.str1 is pointing to character ‘a’ ++*p meAnswer:”p is pointing to ‘n’ and that is incremented by one.” the ASCII value of ‘n’ is 10. then it is incremented to 11. the value of ++*p is 11. ++*str1 meAnswer:”str1 is pointing to ‘a’ that is incremented by 1 and it becomes ‘b’. ASCII value of ‘b’ is 98. both 11 and 98 is added and result is subtracted from 32. i.e. (11+98-32)=77(“M”);

C aptitude 13.3

struct xx
int x=3;
char name[]="hello";

Answer: Compiler Error

Explanation: Initialization should not be done for structure members inside the structure declaration.

Read more Similar C Programs 
Learn C Programming
C Aptitude
C Interview questions




our page!

Share this program with your Facebook friends now! by liking it



To browse more C Programs visit this link
(c) www.c-program-example.com