Total members 11894 |It is currently Thu Nov 21, 2024 4:44 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi everyone.
I am newbie to this forum and I have some troubles with sorting names in c++.
My code is:
int main()
{
string name1, name2,name3;
string store;
cout<<"Enter name1\n";
cin>>name1;
cout<<"Enter name2\n";
cin>>name2;
cout<<"Enter name3\n";
cin>>name3;

if(name1>name2)
{
store=name1;
name1=name2;
name2=store;
}

if(name2>name3)
{
store=name2;
name2=name3;
name3=store;
}
if(name1>name3)
{
store=name1;
name1=name3;
name3=store;
}


cout<<"Alphabetically,those names are:"<<endl;
cout<<name1<<endl<<name2<<endl<<name3<<endl;

system("pause");
return 0;
======================
when I run the program,and if I enter for example John,Bernard and Albert;
I get Bernard,Albert,John.
PS:I want to use only if statement like I tried it .No arrays.
Could any one help me please?




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : c++ general programming
 draw General Path     -  
 General Error: Style data     -  
 General call (Invoke) to method     -  
 ALP programming     -  
 C++ programming     -  
 Different Styles of Programming     -  
 Programming.PHP.2nd.Edition.zip     -  
 Suggest course for programming     -  
 javascript programming     -  
 hello pls i want the codens in c# programming     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com