Question 137

What is the output? void f() {

What is the output? void f() { static int c = 0; c++; printf("%d ", c); } /* f() is called three times */
  1. A0 1 2
  2. B3 3 3
  3. C1 1 1
  4. D1 2 3
Show answerHide answer

Correct answer: (D) 1 2 3

Explanation

A static local keeps its value between calls.

From DSSSB TGT Computer Science Full Mock Test 1

This is question 137 of DSSSB TGT Computer Science Full Mock Test 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.