Monday, 24 April 2017

C language function precedence


Question :


Which of the following is the correct order if calling functions in the below code?a = f1(23, 14) * f2(12/4) + f3();

A) f1, f2, f3
B) f3, f2, f1
C) Order may vary from compiler to compiler
D) None of the above


Answer : A

Explanation : 

#include<stdio.h>
#include<conio.h>
f1(int a,int b)
{
     printf("\nf1");
     return a+b;
}
f2(int n)
{
     printf("\nf2");
     return n;
}
f3()
{
     printf("\nf3");
     return 1;
}
void main()
{
     int a;
     clrscr();
     a=f1(2,3)+f2(12/4)+f3();
     getch();
}