**Ex:**What is the logic to print given number in ascending order. How to print given array elements in ascending order. C program to print given array elements in ascending order.

**Program:**

#include<stdio.h>

void main()

{

int a[]={5,2,7,1,9,10};

int i,j,temp=0;

/*Find size of array a*/

int length=sizeof(a)/sizeof(a[0]);

int length=sizeof(a)/sizeof(a[0]);

//Run loops

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

{

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

{

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

{

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

{

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

{

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

{

## No comments:

## Post a Comment

If you have any doubts, please discuss here...