Q. WAP to take input from user and display the reverse order of entered integers using array
/* Program for reversing elements of arrays */
#include<stdio.h>
int main()
{
int i,j,b[5],a[5];
printf("Enter 5 elements: ");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]); // Taking inputs
}
for(i=0,j=4;i<5;i++,j--)
{
b[i]=a[j]; // Reversing elements
}
printf("Reverse order is :");
for(i=0;i<5;i++)
{
printf(" %d ",b[i]); // Displaying reversed order
}
return 0;
}
Output:
I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Reversing elements of array in C
8:51 AM
array in c
,
C Programs
,
Reversing elements of array in C
,
single dimensional array in C
Edit
0 comments:
Post a Comment