#include <stdio.h>
#include <conio.h>
int f1(int x)
  return x*x;
int f2(int y)
  return 2*y;
int f3(int z)
  return 3*z;
int f4(int p)
  return 4*p;
int main()
  return 0;

Sir Will you please tell me in the printf statement,in which order the fuctions f1,f2,f3 & f4 get executed according to associativity rule?

Thanks in Advance Sir.
Hope you will help me.

f1(1), f2(2), f3(3) and f4(4) may be evaluated in any order whatsoever.

All that we can be sure of is:
a. f1(1), f2(2), f3(3) and f4(4) would be evaluated before printf is entered into.
b. if e1 is the result of evaluating f(1), e2 that of f2(2)and so on, eventhough e1, e2 etc may be evaluated in any order, the final expression would be evaluated as
   1. multiply e2 by e3
   2. add e1 to the result
   3. divide the result of the addition by e4.

Between any two sequence points, sub-expressions may be evaluated in any order.
See: http://en.wikipedia.org/wiki/Sequence_point
And: http://c-faq.com/expr/seqpoints.html  


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2017 About.com. All rights reserved.