Reads eight integers into an array and then prints them in reverse order. - C Data Type

C examples for Data Type:int

Description

Reads eight integers into an array and then prints them in reverse order.

Demo Code

#include <stdio.h>  
#define SIZE 8  //w  w  w  .j  av  a  2s  . c  om
int main( void )  
{  
    int vals[SIZE];  
    int i;      
      
    printf("Please enter %d integers.\n", SIZE);  
    for (i = 0; i < SIZE; i++)  
        scanf("%d", &vals[i]);  
    printf("Here, in reverse order, are the values you entered:\n");  
    for (i = SIZE - 1; i >= 0; i--)  
        printf("%d ", vals[i]);  
    printf("\n");  
                  
    return 0;  
}

Result


Related Tutorials