C Language Examples - Output Array

C Language Examples

Use a for loop to output the array:

Example

#include <stdio.h> int main() { int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; int loop; for(loop = 0; loop < 10; loop++) printf("%d ", array[loop]); return 0; }

The output result is:

1 2 3 4 5 6 7 8 9 0

Use a for loop to output the array in reverse order:

Example

#include <stdio.h> int main() { int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; int loop; for(loop = 9; loop >= 0; loop--) printf("%d ", array[loop]); return 0; }

The output result is:

0 9 8 7 6 5 4 3 2 1

C Language Examples

other extensions