473,320 Members | 2,110 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,320 software developers and data experts.

Sort by ascending

80
Di anyone pls help me out ...when i entered 10 numbers.. i want to group that numbers in to ascending orders as output ..

Did anyone pls help to to dis....
Feb 2 '07 #1
5 1757
horace1
1,510 Expert 1GB
Di anyone pls help me out ...when i entered 10 numbers.. i want to group that numbers in to ascending orders as output ..

Did anyone pls help to to dis....
post the code you have writen so far?
Feb 2 '07 #2
reon
80
Here the code is i want to get output as number is :2 4 8 11 etc...
but the coding is not correct i think so...

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<iostream.h>
  3. #include<conio.h>
  4. class  loops
  5. {
  6. int num;
  7. int times;
  8. public:
  9. void display()
  10. {
  11.     times=0;
  12.     for(;;times++)
  13.     {
  14.     if(times>=10)
  15.         {
  16.         break;
  17.         }
  18.     cout<<endl<<"Enter a number";
  19.     cin>>num;
  20.     num=num;
  21.     }
  22. }
  23. void output();
  24. };
  25. void loops::output()
  26.     {
  27.     num=0;
  28.     for(;;num++)
  29.         {
  30.         if(num>=10)
  31.             {
  32.             break;
  33.             }
  34.             cout<<endl<<"Number is :"<<num;
  35.         }
  36.     }
  37. void main()
  38. {
  39. clrscr();
  40. loops l1;
  41. l1.display();
  42. l1.output();
  43. getch();
  44. }
  45.  
Feb 2 '07 #3
horace1
1,510 Expert 1GB
tided it up a bit and the data is now stored in an array
Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2.  
  3. class  loops
  4. {
  5. public:
  6. void display(int num[10])
  7. {    
  8.     int times;
  9.     for(times=0;times<10;times++)
  10.     {
  11.     cout<<endl<<"Enter a number";
  12.     cin>>num[times];
  13.     num=num;
  14.     }
  15. }
  16.  
  17. void loops::output(int num[10])
  18.     {
  19.     int n;
  20.     for(n=0;n<10;n++)
  21.         {
  22.             cout<<endl<<"Number is :"<<num[n];
  23.         }
  24.     }
  25. };
  26. int main()
  27. {
  28. int num[10];
  29. //clrscr();
  30. loops l1;
  31. l1.display(num);
  32. l1.output(num);
  33. getchar();
  34. }
  35.  
you now need to sort the data in the array!
don't use conio.h unless you have a good reason - it is non standard and not available with many compilers.

also if possible replace
Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
which uses a deprecated header with
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3.  
however, this does not work with many older compilers
Feb 2 '07 #4
reon
80
Any way thanx for the info: its running.. but i am using an old complier and in that conio.h is compulsory ... i tried a lot in that scenario....So anyway thanking u again.....

Reon
Feb 2 '07 #5
reon
80
now i entered that numbers and stored it in arrays ..but i want to sort that into ascending orders.. hows is it .. is there any keyword in c++ like (asc and desc in sql)....
Feb 5 '07 #6

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

Similar topics

2
by: Ken R. | last post by:
Hello all, I am relatively new to python but I am having an issue with custom sort functions.. I am trying to sort a list of lists or tuples with arbitrary ascending or descending sorts. For...
3
by: Petterson Mikael | last post by:
Hi, I have the following package names ( in an xml) that I will transform to html. I need to sort them. <package name="se.company.product.subproduct.boam.fpx.testsignals"> <package...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
15
by: bcochofel | last post by:
Hi, I want to use a variable to sort elements. That var his passed with query string (I'm using Perl CGI to generate XML). Here's a sample of my output:...
13
by: Vbbeginner07 | last post by:
its about Sorting a list view but its not working. please help....... Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) 'Determine whether the column is the same...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.