Q. Write a C program to display the array in reverse order.
Ans.
/*c program for display the array in reverse order*/
#include<stdio.h>
#include<conio.h>
#define SIZE 50
int main()
{
int arr[SIZE];
int i,index,tmp,num;
printf("Enter total number of element in array : ");
scanf("%d", &num);
for(i=0; i<num; i++)
{
printf("Enter %d element : ",i+1);
scanf("%d", &arr[i]);
}
printf("\n-- Array in reverse order --\n\n");
for(i=0; i<num; i++);
for(i--; i>=0; i--)
printf("\t%d\n",arr[i]);
getch();
return 0;
}
/************* Output *********************/
Related Programs:
Ans.
/*c program for display the array in reverse order*/
#include<stdio.h>
#include<conio.h>
#define SIZE 50
int main()
{
int arr[SIZE];
int i,index,tmp,num;
printf("Enter total number of element in array : ");
scanf("%d", &num);
for(i=0; i<num; i++)
{
printf("Enter %d element : ",i+1);
scanf("%d", &arr[i]);
}
printf("\n-- Array in reverse order --\n\n");
for(i=0; i<num; i++);
for(i--; i>=0; i--)
printf("\t%d\n",arr[i]);
getch();
return 0;
}
/************* Output *********************/
Screen shot of display array in reverse order |
Related Programs:
No comments:
Post a Comment