Input :
Array[5]={10,20,30,40,50};
Output:
50,40,30,20,10
/*
C program to display elements in
reverse order: program will not change the order in memory.it will simply display in reverse order
*/
*/
#include<stdio.h>
int
main(){
int array[10];
int i;
//Entering numbers into array
for(i=0; i<10; i++){
printf("Enter a number\n");
scanf("%d",&array[i]);
}
//Reading and Displaying numbers from array in their original order
printf("\nArray elements in their
original order:\n");
for(i=0;i<10;i++){
printf("%d\t",array[i]);
}
printf("\nArray elements in reverse
order:\n");
//Reading and Dislaying numbers from array in reverse order
for(i=9;i>=0;i--){
printf("%d\t",array[i]);
}
printf("\n");
return 0;
}
Output:
Please comment if you find anything incorrect, or you want to improve the topic discussed above.
No comments:
Post a Comment