Section 4. Chapter 7
single
For Loop Practice
Swipe to show menu
Example from the Previous Lesson
main.c
1234567891011121314#include <stdio.h> int main() { int array[] = { 3, 6, 2, 134, 45, 2, 564, 8, 3, 531 }; for (int i = 0; i < 10; i++) { printf("Index of element: %d\tValue of element: %d\n", i, array[i]); } return 0; }
Task
Swipe to start coding
Write a for loop that starts with i = 10 and counts down to 0. On each iteration, print the current value of i on a new line. The program should display all numbers from 10 to 0, including both 10 and 0.
Solution
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 7
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat