C program aptitude questions, answers and explanation for interview preparations.
In this site, We discussed various type of C programs, now we are moving into further steps by looking at the c aptitude questions.
This questions and answers are helpful to freshers and job hunters. C interview questions are from various companies and experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.
C aptitude 1.1
int const * p=5;
Answer: Compiler error: Cannot modify a constant value.
Explanation: p is a pointer to a “constant integer”. But we tried to change the value of the “constant integer”.
C aptitude 1.2
char s[ ]="man";
for(i=0;s[ i ];i++)
printf("n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
Answer: mmmm aaaa nnnn
Explanation: s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].
C aptitude 1.3
float me = 1.1;
double you = 1.1;
printf("I love U");
printf("I hate U");
Answer: I hate U
Explanation: For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double. Rule of Thumb: Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .
Read more Similar C Programs
Learn C Programming
C Interview questions
You can easily select the code by double clicking on the code area above.
To get regular updates on new C programs, you can Follow @c_program
You can discuss these programs on our Facebook Page. Start a discussion right now,
Share this program with your Facebook friends now! by liking it
(you can send this program to your friend using this button)
Like to get updates right inside your feed reader? Grab our feed!