QA – Placement Quizzes | SP Contest 2 | Question 3

What will be the output of the below C program:

filter_none

edit
close

play_arrow

link
brightness_4
code

int calc(int i)
{
      
    while(++i > 10); // statement 0
      
    i++;
      
    return i;
}
  
int main() {
    int i = 2;
      
    printf("%d", calc(i));
      
    return 0;
}

chevron_right


Also, if we replace pre-increment operator by post-increment operator in statement 0, then what will be the output of the new program?

(A) 11 and 12
(B) 12 and 11
(C) 4 and 5
(D) 4 and 4


Answer: (D)

Explanation:

Quiz of this Question
Please comment below if you find anything wrong in the above post



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.