Easy Tutorial
❮ C Examples Check Armstrong Number C Variables ❯

C Language Example - Output Array

C Language Examples

Output an array using a for loop:

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 is:

1 2 3 4 5 6 7 8 9 0

Output an array in reverse using a for loop:

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 is:

0 9 8 7 6 5 4 3 2 1

C Language Examples

❮ C Examples Check Armstrong Number C Variables ❯