Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C sorting arrays help

Status
Not open for further replies.

Cleong

Member level 2
Joined
Feb 17, 2006
Messages
53
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,789
How to write a simple code for sorting an array [2 6 1 7 9] for Descending Order

thanks
 

simplest way is bubble sort, sample code can be:

**broken link removed**
 

const int size =5;
int temp;
int x[size]={2, 6, 1, 7, 9};
for(int i=0;i<size-1;i++)
for(int j=i+1;j<size;j++)
if(x<x[j]){temp=x;x=x[j];x[j]=temp;}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top