‘C’ program to accept an array of n float values and display them in the reverse order.

C File =>


/* Write a ‘C’ program to accept an array of n float values and display  them in the reverse order. */

#include<stdio.h>
int main() 
{
      int n,i;
      float arr[30];
      printf("\n How many elements? ");
      scanf("%d",&n);
     // Accepting input
     for(i=0;i<n;i++)
    {
        printf("\n Enter element%d : ",i+1);
        scanf("%f",&arr[i]);
     }
     printf("\n Array elements in Reverse order : \n");

      for(i=n-1;i>=0;i--)
            printf("%.2f\t",arr[i]);
      return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.