473,396 Members | 1,766 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,396 software developers and data experts.

Printing Numbers in Ascending Order

Hi Everyone,

I am trying to create a program that arranges numbers in ascending order. I do not understand how to do this.

To start, think that I would need to include several if and else if statements coming values. Than I would use the operators ">" and "<" to compare the int values I have already declared. Could someone explain how to do this?

Thanks in advance.
Feb 25 '07 #1
4 5316
Ganon11
3,652 Expert 2GB
How will the numbers be stored? Will the be in an array or some other data structure?
Feb 25 '07 #2
How will the numbers be stored? Will the be in an array or some other data structure?
Umm. I'm really not sure. I am declaring them as "int." Is this what you mean?
Feb 25 '07 #3
Ganon11
3,652 Expert 2GB
Well, I gathered they would be ints, but in order to sort them, I assumed you had to store them somewhere. How exactly are you supposed to get these numbers, and when will they be sorted?
Feb 25 '07 #4
You should use any data structure like array etc..you get numbers in array,and use the logic like
int[] a = new int[5] { 4, 2, 6, 1, 5 };
int temp;
for (int i = 0; i <4; i++)
{
for (int j = 1; j <= 4; j++)
{
if (a[i] > a[j])
{
temp = i;
i = j;
j = temp;
}
}
Console.WriteLine("ASCENDING : {0}", a[i]);
}
Oct 17 '07 #5

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

Similar topics

0
by: renster | last post by:
I have been looking at implementing the following but with a difference. http://forums.devshed.com/t47653/s.html This example uses a link which works with some code shown on the page. I have...
2
by: Alpay Eno | last post by:
Hello all... I'm using asp to get records from an access database, very similar to the way datagrid would work. The title of each column in my table is a link that alternates the sort order between...
2
by: Christopher M. Pieper | last post by:
I want to generate a resultset that is just a series of numbers in ascending order or perhaps a series of dates.. What I mean is, is there a way to generate a temporary table of dates given an...
6
by: sriram | last post by:
Hi, I have been seing a weird problem with db2look tool in db2 8.2 on Windows 2000 platform. When i spool the DDL using db2look, it spools the DDL in the ascending order of database objects...
5
by: M.Stanley | last post by:
Hi, I'm attempting to create a query that will combine 2 columns of numbers into one. The followng comes from 1 table with 4 fields (A,B,C,D) A B RESULT 700 000 700000 700 001 ...
3
by: cess | last post by:
If the user input three numbers, say (1,3,2), how it will become 1,2,3 or in ascending order?? there is something wrong/lacking with my code, help plzzzz!! import java.io.*; public class sign {...
6
by: flyaway888 | last post by:
Hey, I have a function that compares 2 arrays with 6 numbers in each and outputs the matching numbers. I have written a function that does this but I need to output the numbers in ascending order...
5
by: bigmac | last post by:
I need to order four numbers and print in ascending order. I'm having troubles coming up with an algorithm to solve this. I should be able to write the code if I got something to work off of. Thanks.
1
by: pratimapaudel | last post by:
Can anyone help me to do this problem? Question goes like below: Use C or Borne shell. Take two integer command line arguments. The script should display the numbers between the two integers...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.