Program to accept a list of numbers and display it in reverse order using function concept

This program accepts a list of numbers and displays it in reverse order using function concept.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdio.h"
#include "conio.h"
 
int a[5],b[5];
 
void accept()
{
   int j;
   printf("Enter the list \n");
   for(j=0;j=0;j--,i++)
   {
     b[i]=a[j];
   }
}
 
void display()
{
   int j;
   printf("The list in reverse is \n");
   for(j=0;j<5;j++)
   printf("%d ",b[j]);
   printf("\n");
}
 
void main()
{
   accept();
   reverse();
   display();
getch();
}

Output:

Enter the list
5
4
3
2
1
The list in reverse is
1 2 3 4 5

2 Responses to “Program to accept a list of numbers and display it in reverse order using function concept”

Leave a Reply