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
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
Science,
9 days ago
Political Science,
9 days ago
Math,
9 days ago
Computer Science,
19 days ago
Math,
19 days ago
Science,
9 months ago
English,
9 months ago
Math,
9 months ago