Computer Science, asked by dhivya0220s, 19 days ago

Find the output int printCount(int count) { for (;;) { if (count == 10) break; printf("%d", ++Count); } return 0; What will be the output for the function call printCount(2)?​

Answers

Answered by amproc
0

Answer:

3456789

(Check explanation to know why there are no spaces)

Explanation:

Let's rewrite your program for better readability and to understand it better.

int printCount(int count) {

  for (;;) {

     if (count == 10) break;

     printf("%d", count++);

  }

}

return 0;

The program basically uses a infinite loop (;; means true) that will only break when count is equal to 10. Then after the conditional statement, a printf function increments (means to add by 1) the integer "count". Note that printf does not print the next output in a newline. This keeps on happening until count reaches 10, and then it breaks the forever loop.

Similar questions