0

What is the correct order for the calling function of the code given below?

a=f1(23,14)*f2(12/4)*f3();

3rd Sep 2018, 12:12 PM
Akshay Kumbhar
Akshay Kumbhar - avatar
4 Answers
+ 6
Adding to my reply, the order of which function is executed first, is unspecified. Although we know that * has left to right associativity, it is dependent on the compiler whether or not it would execute f1 first, or f2. https://en.cppreference.com/w/c/language/eval_order
3rd Sep 2018, 12:44 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
As stated in: https://en.cppreference.com/w/c/language/operator_precedence Both () and * operator has a left-to-right associativity. () has higher precedence, so the function calls are resolved accordingly before the values are multiplied and assigned to a.
3rd Sep 2018, 12:41 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Akshay just to go off track, it doesn't matter in which order function is called... all function call is call by value and all return value is multiplied to get answer, order doesn't matter for this output...
3rd Sep 2018, 3:01 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Ketan Lalcheta Ketan Lalcheta I wanted to know how memory allocation sequence is decided for above functions.
3rd Sep 2018, 4:43 PM
Akshay Kumbhar
Akshay Kumbhar - avatar