Write a ‘c’ program to accept n numbers from user , store these numbers into an array and reverse an array element using function
#include<stdio.h>
#include<conio.h>
void main()
# define SIZE 50
{
void rev(int);
int n;
clrscr();
printf("\n enter the limit\n");
scanf("%d",&n);
rev(n);
getch();
}
void rev(int n)
{
int r[SIZE],i=0;
printf("\n enter the array\n");
for(i=0;i<n;i++)
{
scanf("%d",&r[i]);
}
printf("\n entered array is\n");
for(i=0;i<n;i++)
{
printf("\n %d",r[i]);
}
printf("\n reverse the array\n");
for(i=n-1;i>=0;i--)
{
printf("\n%d",r[i]);
}
}
/* output
enter the limit
5
enter the array
1
2
3
4
5
entered array is
1
2
3
4
5
reverse the array
5
4
3
2
1
*/
#include<conio.h>
void main()
# define SIZE 50
{
void rev(int);
int n;
clrscr();
printf("\n enter the limit\n");
scanf("%d",&n);
rev(n);
getch();
}
void rev(int n)
{
int r[SIZE],i=0;
printf("\n enter the array\n");
for(i=0;i<n;i++)
{
scanf("%d",&r[i]);
}
printf("\n entered array is\n");
for(i=0;i<n;i++)
{
printf("\n %d",r[i]);
}
printf("\n reverse the array\n");
for(i=n-1;i>=0;i--)
{
printf("\n%d",r[i]);
}
}
/* output
enter the limit
5
enter the array
1
2
3
4
5
entered array is
1
2
3
4
5
reverse the array
5
4
3
2
1
*/
Comments
Post a Comment