#include<stdio.h>
#define SIZE 100
void reorder (int, int[]);
int main()
{
int i,n,x[SIZE];
printf("How many numbers?");
scanf("%d",&n);
//read the list of numbers
for(i=0;i {
printf("x[%d]=",i+1);
scanf("%d",&x[i]);
}
//record all array elements
reorder(n,x);
//display the re- order list of number
for(i=0;i {
printf("\nx[%d]=%d\n",i+1,x[i]);
}
return 0;
}
void reorder(int n,int x[])
{
int i,item,temp;
for(item=0;item {
for(i=item+1;i {
if (x[i] {
//inter change two elements
temp = x[item];
x[item]=x[i];
x[i]=temp;
}
}
}
}



OUTPUT

C program to print the number in ascending order using function (passing array function)

Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours