Q:

Write a function that returns 0 when it is first called and then generates numbers in sequence each time it is called again

0

 Write a function that returns 0 when it is first called and then generates numbers in sequence each time it is called again.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

int foo() {
  static int cnt = 0;
  return cnt++;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now