C Aptitude 27C 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.
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 27.1
main()
{
int i;
i = abc();
printf("%d",i);
}
abc()
{
_AX = 1000;
}
Answer: 1000
Explanation: Normally the return value from the function is through the information from the accumulator. Here _AX 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 27.2
// If the inputs are 0,1,2,3 find the o/p
int i;
main()
{
int t;
for ( t=4;scanf("%d",&i)-t;printf("%dn",i))
printf("%d--",t--);
}
Answer: 4–0 3–1 2–2
Explanation:Let us assume some x= scanf(“%d”,&i)-t the values during execution will be, t i x 4 0 -4 3 1 -2 2 2 0
C aptitude 27.3
int a,b;
func(a,b)
{
return( a= (a==b) );
}
main()
{
int process(),func();
printf("The value of process is %d !n ",process(func,3,6));
}
int val1,val2;
process(pf,val1,val2)
int (*pf) ();
{
return((*pf) (val1,val2));
}
Answer:The value if process is 0 !
Explanation: The function ‘process’ has 3 parameters – 1, a pointer to another function2 and 3, integers. When this function is invoked from main, the following substitutions for formal parameters take place: func for pf, 3 for val1 and 6 for val2. This function returns the result of the operation performed by the function ‘func’. The function func has two integer parameters. The formal parameters are substituted as 3 for a and 6 for b. since 3 is not equal to 6, a==b returns 0. therefore the function returns 0 which in turn is returned by the function ‘process’.
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!
–>
To browse more C Programs visit this
link