Total members 10259 | Gratitudes |It is currently Mon May 21, 2012 4:32 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Topic
 Topic subject: c++ general programming
PostPosted: Sat Apr 11, 2009 7:16 pm 
Offline
Newbie
User avatar

Joined: Sat Apr 11, 2009 7:04 pm
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

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?


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 programming
 c++ programming
 programming
 Programming
 ALP programming
 hello pls i want the codens in c# programming
 Suggest course for programming
 javascript programming
 C++ programming
 i want some help in java programming

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Topic | Next Topic 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team