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.
–> Predict the output or error(s) for the following:
C aptitude 30.1
i = abc();
_AX = 1000;
Explanation: Normally the return value from the function is through the information from the accumulator. Here _AH is the pseudo global variable denoting the accumulator. Hence, the value of the accumulator is set 1000 so the function returns value 1000.
C aptitude 30.2
char ch = ‘g’, *cp = “goofy”;
int j = 20;
vp = &ch;
printf(“%c”, *(char *)vp);
vp = &j;
vp = cp;
printf(“%s”,(char *)vp + 3);
Explanation: Since a void pointer is used it can be type casted to any other type pointer. vp = &ch stores address of char ch and the next statement prints the value stored in vp after type casting it to the proper data type pointer. the output is ‘g’. Similarly the output from second printf is ‘20’. The third printf statement type casts it to print the string from the 4th value hence the output is ‘fy’.
C aptitude 30.3
Explanation: ptr is array of pointers to functions of return type int.ptr is assigned to address of the function aaa. Similarly ptr and ptr for bbb and ccc respectively. ptr() is in effect of writing ccc(), since ptr points to ccc.
Read more Similar C Programs
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!