For Loop Practice
Example from the Previous Lesson
main
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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;
}
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; }
Tâche
Swipe to start coding
Use the for
loop to display numbers from 10 down to 0 on the screen.
Solution
99
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int main()
{
for (int i = 10; i >= 0; i--)
{
printf("%d\n", i);
}
return 0;
}
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 7
99
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int main()
{
for (int i = 10;___;___)
{
printf("%d\n", i);
}
return 0;
}
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion