| | |
print a number in ordered form
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2004
Posts: 7
Reputation:
Solved Threads: 0
I am being asked to take a number like 86249 and produce the output 24689. Basically take a number and print it in ordered form. I can do this with an array of multiple numbers, but can't figure out how to split the number entered into an array so this can be done. Am I following the right logic or am I way off base?
C++ Syntax (Toggle Plain Text)
#include<iostream.h> void main() { int arr[50]; int size, temp; do{ cout<<"Enter the size of the array(max 50): "; cin>>size; }while(size>50 || size <1); cout<<"\nEnter the values: "; for(int i=0; i<size; i++) cin>>arr[i]; for(i=0; i<size-1;i++) for(int j=i+1; j<size;j++) if(arr[i]>arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } cout<<"\nthe sorted array is: "; for(i=0; i<size; i++) cout<<arr[i]; cout<<"\n"; }
![]() |
Similar Threads
- Get first number from query into new form (Database Design)
- print, number of character from a file (Perl)
- print the number 7011 as 011 (take off a 7) (C)
- How to print a character in bold form. (C)
- print large pricturebox or form in vb6 (Visual Basic 4 / 5 / 6)
- Stuck a bit on input (C)
- Populating a fields on a form base on a selected item from a droplist. (PHP)
Other Threads in the C++ Forum
- Previous Thread: help with getting soda machine program running
- Next Thread: Need help with a function
Views: 1723 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





