What is an example of iteration in C?
for loop
while loop
do-while loop
repeatedly execute a block of code until a certain condition is met.
here an example :-
#include <stdio.h>
int main() {
// Define an array of integers
int numbers[] = {1, 2, 3, 4, 5};
// Iterate over the array using a for loop
printf("Using for loop:\n");
for (int i = 0; i < 5; i++) {
printf("%d\n", numbers[i]); // Print each element
}
return 0;
}
output:-
Using for loop:
1
2
3
4
5
0 కామెంట్లు