User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 397,768 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,478 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 1321 | Replies: 0
Reply
Join Date: Dec 2004
Location: Nashville, TN
Posts: 7
Reputation: dowens3rd is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dowens3rd dowens3rd is offline Offline
Newbie Poster

print a number in ordered form

  #1  
Dec 8th, 2004
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?
#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";
}
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 4:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC