C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.
In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.
In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.
The C aptitude questions and answers for those questions along with explanation for the interview related queries.
We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.
C aptitude 17.1
int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
}
Answer: Runtime error: Abnormal program termination. assert failed (i<5), ,
Explanation: sserts are used during debugging to make sure that certain conditions are satisfied. If assertion fails, the program will terminate reporting the same. After debugging use, #undef NDEBUG and this will disable all the assertions from the source code. Assertion is a good debugging tool to make use of.
C aptitude 17.2
main()
{
int i=-1;
+i;
printf("i = %d, +i = %d n",i,+i);
}
Answer: i = -1, +i = -1
Explanation:Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just because it has no effect in the expressions (hence the name dummy operator).
C aptitude 17.3
main()
{
char *cptr,c;
void *vptr,v;
c=10; v=0;
cptr=&c; vptr=&v;
printf("%c%v",c,v);
}
Answer:Compiler error (at line number 4): size of v is Unknown.
Explanation: You can create a variable of type void * but not of type void, since void is an empty type. In the second line you are creating variable vptr of type void * and v of type void hence an error.
Read more Similar C Programs
Learn C Programming
C Aptitude
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,
our page!
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!