Basic Points:-
- After every expression statement in the for loop, there is a sequence point
- After the return value is copied, there is a sequence point.
for loop execution :- for(e1;e2;e3)
On the first iteration, expression$1$ executed ( generally termed as initialization expression,)
next expression$2$ executed ( generally termed as condition check expression, if it evaluates to non-zero then only, for loop body executed, otherwise for loop terminates.)
After the first iteration, expression$3$ is executed ( generally termed as increment expression. ), after that $e2$ evaluates and the process continues!
$\text{for}(\color{green}{r()};\color{red}{r()};\color{blue}{r()})$
{
printf("%d",r());
}
before the main starts, the execution num is initialized with $7$ ( note that it is stored under static memory due to it is a static number.)
on first iteration :- $\color{green}{r()} \implies$ return $7$ but num changed to $6$.
$\color{red}{r()} \implies$ return $6$ but num changed to $5. \implies$ condition evaluate to true $\implies$ for loop body executes !
printf("%d",r()); $\implies$ return $5$ but num changed to $4. \implies$ print $5$ on the screen.
$\color{blue}{r()} \implies$ return $4$ but num changed to $3$.
$\color{red}{r()} \implies$ return $3$ but num changed to $2. \implies$ condition evaluate to true $\implies$ for loop body executes !
printf("%d",r()); $\implies$ return $2$ but num changed to $1. \implies$ print $2$ on the screen.
$\color{blue}{r()} \implies$ return $1$ but num changed to $0$.
$\color{red}{r()} \implies$ return $0$ but num changed to $-1. \implies$ condition evaluate to false $\implies$ for loop over !
Hence option $B$ : $52$