Read the question, write C on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read n and print the numbers from n down to 1, space-separated on one line.
Input. One integer n ≥ 1.
Output. n space-separated integers, descending.
Constraints
- 1 ≤ n ≤ 50
Examples
Input
5
Output
5 4 3 2 1
Hint
- for (int i = n; i >= 1; i--) printf("%d ", i);
Show correct code
Peek only after you have tried. You can still Check your own version.
#include <stdio.h>
int main(void) {
int n;
if (scanf("%d", &n) == 1) {
for (int i = n; i >= 1; i--) printf("%d ", i);
printf("\n");
}
return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.