answersLogoWhite

0


Best Answer

//C program for Arranging 5 Numbers in Ascending Order

#include<stdio.h>

#include<conio.h>

void main()

{

int a[5],i,j,t;

clrscr();

printf("Enter 5 nos.\n\n");

for (i=0;i<5;i++)

scanf("%d",&a[i]);

for (i=0;i<5;i++)

{

for(j=i+1;j<5;j++)

{

if(a[i]>a[j])

{

t=a[i];

a[i]=a[j];

a[j]=t;

}

}

}

printf("Ascending Order is:");

for(j=0;j<5;j++)

printf("\n%d",a[j]);

getch();

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Sort array in ascending descending order using function in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Sort array in ascending descending order in python?

Using sorted(array,reverse=True)


How do you sort variable in ascending or descending order both in php?

Assuming that the values are stored in an array, you can use the php function sort($array) to sort ascending, and rsort to sort descending. The following link gives a table that lists all of the built in PHP sort functions: http://php.net/manual/en/array.sorting.php


Which action do you perform on a data source to reorganize the order of the record for a merge?

You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.


Can Data can only be sorted in ascending order.?

No, it can be sorted either in ascending or descending order.


What is data organized in ascending or descending order?

The data that is being organized in ascending or descending order is the numbers or the alphabet. Ascending means is from lowest to highest and descending means from highest to lowest.


What does descending mean in maths?

In Maths, we often talk about ascending and descending order. Ascending order is writing numbers from smallest to largest. Descending order is writing numbers from largest to smallest.


A collection of pitches arranged in ascending and descending order constitutes a?

A collection of pitches arranged in ascending and descending order constitutes a scale.


Can Data only be sorted in ascending order?

No, it can be sorted either in ascending or descending order.


What does descending in alphabetical order mean?

Ascending order


Can data be stored in ascending order?

Data can be stored in ascending order, descending order or no particular order.


What word contains all vowels in descending order?

Abstemious for ascending order Suncontinental for descending order


Data can only be stored in ascending order?

Data can be stored in ascending order, descending order or no particular order.