GATE CS 2024 Set 2 | Question 13
Programming & Data Structures › Functions · MCQ · 1 mark · Answer: A
- Question 13Programming & Data Structuresmcq1 markParameters are evaluated right to left.
Correct output?int g(int p){printf("%d",p);return p;} int h(int q){printf("%d",q);return q;} void f(int x,int y){ g(x); h(y); } int main(){ f(g(10),h(20)); }- A.20101020✓
- B.10202010
- C.20102010
- D.10201020
Answer: A
Solution
Answer: (A) 20101020f(g(10), h(20)): arguments evaluated right-to-left, soh(20)prints 20, theng(10)prints 10 -> "2010". Then insidef,g(x)prints 10,h(y)prints 20 -> "1020". Total: "2010"+"1020" = "20101020". - A.
More GATE PYQ on Functions
All GATE CS Programming & Data Structures PYQ →Attempt GATE CS 2024 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →