Thursday, 21 June 2012

write a c program to calculate accept n number from user store these number into an array & reverse the array element by using function


/*write a c program to calculate accept n number from user store these number
into an array & reverse the array element by using function */
#include<stdio.h>
#include<conio.h>
void display();
void main()
{
clrscr();
display();
getch();
}
void display()
{
int k=0,i,n;
int a[20];
printf("\nhow many number :");
scanf("%d",&n);
printf("\nenter the number :");
for(i=0;i<n;i++)
{
k++;
scanf("%d",&a[i]);
}
k=k-1;
printf("the reverse number are :\n");
for(i=k;i>=0;i--)
{
printf("\n%d",a[i]);
}
}
/*
how many number :4                                                            
                                                                             
enter the number :1 3 8 4                                                    
the reverse number are :                                                      
                                                                             
4                                                                            
8                                                                            
3                                                                            
1                                                                            
*/

No comments: