473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

find 5th smallest element from array?

anu401
9
how to find out the 5 th smallest element from the following array?
10,20,30,40,50,60,70,80,90,100.
no need of program for me i need only the sum
i need only that mechanism....
i need how the loop works and how that numbers are used in loops.........please help
Jul 11 '10 #1
6 3045
weaknessforcats
9,208 Expert Mod 8TB
Sort the array.

Then pick the 5th element of the sorted array.
Jul 11 '10 #2
anu401
9
already it looks like sorted element how to choose smallest element i cant get the answer
i dont know how the loop works
Jul 11 '10 #3
jkmyoung
2,057 Expert 2GB
What is this loop that you are referring to? Do you have the code for it?
Jul 12 '10 #4
Oralloy
988 Expert 512MB
Likely you simply want the fifth array element, for example "a[4]", if you'd sorted the elements into array "a".

Of course, if there are less than five elements in your array, you'll have to fail appropriately.

Still, if you post code, we might be able to help you better.
Jul 12 '10 #5
for(i=0;i<10;i++)
{
for(j=1+1;j<10;j++)
{
if(a[i]>a[j])
{
a[i]=k;
a[i]=a[j];
a[j]=k;
}
}
}

THIS IS USED FOR SORTING OF 10 NUMBERS IN ASCENDING ORDER
MODIFY YOUR PROGRAM BY PRINTING THE FIFTH ELEMENT
Jul 14 '10 #6
donbock
2,426 Expert 2GB
Change 7th line from
Expand|Select|Wrap|Line Numbers
  1. a[i] = k;
to
Expand|Select|Wrap|Line Numbers
  1. k = a[i];
Please use CODE tags.
Jul 14 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: J. J. Cale | last post by:
In IE6 both these functions *seem* to be working. I don't see much recursion in this group except the occasional setTimeout problems. Besides the obvious stack problems that can occur if one...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
33
by: Zytan | last post by:
I want to make a zero element array. I know that Nothing is not the same as a zero element array, since I can't get the length of, or iterate through, an array = Nothing. I could make a zero...
17
by: Ron Peterson (012ED25E) | last post by:
I ran into something like the following while looking into how the GNU MP library implements its mpz_t type. typedef struct { int len; char *buf; } foo; This is an interesting technique. ...
26
by: mike-yue | last post by:
The topic comes from a question: Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1Quicksort 2Linear Search 3Bubble Sort ...
8
by: Sunny | last post by:
Hi, do someone know, How we can find the smallest distance between a bunch of lat 7 long? Like I have 10 Latitude & Longitude. -73.924598,40.879010 -73.924506,40.878978 -73.924506,40.878978...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.