What is the output of the following code?#include <stdio.h>int main() { for (int i = 0; i < 5; i++) { for (int j = 5; j > 0; j--) { if (i > j) continue; printf("%d%d ", i, j); } printf("\n"); } return 0;}
Question
What is the output of the following code?#include <stdio.h>int main() { for (int i = 0; i < 5; i++) { for (int j = 5; j > 0; j--) { if (i > j) continue; printf("%d%d ", i, j); } printf("\n"); } return 0;}
Solution
The output of the given C code will be:
04 03 02 01 0
14 13 12 11
24 23 22
34 33
44
This is because the outer loop runs from 0 to 4 (inclusive) and the inner loop runs from 5 to 1 (inclusive). The 'if' condition checks if 'i' is greater than 'j', if true it skips the current iteration and moves to the next one. If 'i' is not greater than 'j', it prints the values of 'i' and 'j'. After each iteration of the outer loop, it prints a newline character.
Similar Questions
What will be the output of the following code snippet?
What is the output of the following code in Python?
What will be the output of the following C code?
What is the output for the following code?Note: This question helps in clearing conceptual technical interviews for service-based companies.
What will be the output of the following C++ code?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.