C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-09-2009, 03:24 AM   #16
Registered User
 
Join Date: Apr 2006
Location: United States
Posts: 3,201
Well there's your mistake. The op had a big problem with his conditions earlier, so if I was going to post an answer in code, I would do my best to make sure the conditions worked. Yours don't, so I made a comment.
__________________
Os iusti meditabitur sapientiam
Et lingua eius loquetur indicium

"There is nothing either good or bad, but thinking makes it so." (Shakespeare, Hamlet, Act II scene ii)

http://www.myspace.com/whiteflags99
whiteflags is offline   Reply With Quote
Old 07-09-2009, 03:28 AM   #17
C++0x User
 
Tux0r's Avatar
 
Join Date: Nov 2008
Location: Sweden
Posts: 133
Or you could refactor away all the junk and just go with:
Code:
#include <iostream>

int main() {
    std::cout<<"Megan Fox is the hottest girl!"<<std::endl;
}
Tux0r is offline   Reply With Quote
Old 07-09-2009, 05:04 PM   #18
Banned
 
ಠ_ಠ's Avatar
 
Join Date: Mar 2009
Posts: 533
Quote:
Originally Posted by Tux0r View Post
Or you could refactor away all the junk and just go with:
Code:
#include <iostream>

int main() {
    std::cout<<"Megan Fox is the hottest girl!"<<std::endl;
}
you forgot to return 0
__________________
╔╗╔══╦╗
║║║╔╗║║
║╚╣╚╝║╚╗
╚═╩══╩═╝
ಠ_ಠ is offline   Reply With Quote
Old 07-09-2009, 07:51 PM   #19
Registered User
 
Join Date: Sep 2004
Location: California
Posts: 2,845
Quote:
Originally Posted by ಠ_ಠ View Post
you forgot to return 0
No he didn't.
bithub is offline   Reply With Quote
Old 07-09-2009, 08:49 PM   #20
Banned
 
ಠ_ಠ's Avatar
 
Join Date: Mar 2009
Posts: 533
Quote:
Originally Posted by bithub View Post
No he didn't.
prove it
__________________
╔╗╔══╦╗
║║║╔╗║║
║╚╣╚╝║╚╗
╚═╩══╩═╝
ಠ_ಠ is offline   Reply With Quote
Old 07-09-2009, 10:54 PM   #21
Registered User
 
Join Date: Sep 2004
Location: California
Posts: 2,845
C++ does not require an explicit return statement from main.
Quote:
Originally Posted by c++ standard
3.6.1 Main function

A return statement in main has the effect of leaving the main function
(destroying any objects with automatic storage duration) and calling
exit with the return value as the argument. If control reaches the
end of main without encountering a return statement, the effect is
that of executing
return 0;
bithub is offline   Reply With Quote
Old 07-13-2009, 01:10 AM   #22
Registered User
 
Join Date: Jul 2009
Posts: 20
Quote:
Originally Posted by Aliaks View Post
May I suggest using a do while loop?

Code:
#include <iostream>

using namespace std;

int main()
{
	int HottestGirl = 0;

	cout << "Who is the hottest girl?\n";
	cout << "1)Claudia Lynx\n";
	cout << "2)Megan Fox\n";
	cout << "3)Audrina Patridge\n";
	cout << "\n";

//------------------------------------------------------------------------------------------------------------------------// START   //
    do {                                                                                                                  // Do While -
        cin >> HottestGirl;                                                                                               // Input
        if (HottestGirl == 1) {                                                                                           // Set Case If
            cout << "\nClaudia Lynx is the hottest girl!\n\n";
        }
        else if (HottestGirl == 2) {                                                                                      // Set Case If
            cout << "\nMegan Fox is the hottest girl!\n\n";
        }
        else if (HottestGirl == 3) {                                                                                      // Set Case If
            cout << "\nAudrina Patridge is the hottest girl!\n\n";
        }
        else {                                                                                                            // If none above then do
            cout << "Invalid Selection\n\n";
        }
    } while (HottestGirl == 0);                                                                                           // Do the above while HottestGirl equals 0


}
hmm... I understand that except for the last part where it says:
Code:
    } while (HottestGirl == 0);
What is this there for?
Also, one thing this doesn't do is display "Selection: " before the user inputting the selection. Is there a way to fix this or no? It's not that it's so important, the program means nothing, I am just trying to learn

Last edited by PersianStyle; 07-13-2009 at 01:14 AM.
PersianStyle is offline   Reply With Quote
Old 07-13-2009, 04:09 AM   #23
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
You need to put effort into getting a book, because loops is one basic thing all programmers must know.
If you don't have one, I would recommend getting Accelerated C++.
This loop simply says: loop WHILE HottestGirl equal 0.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help to compile this code... wise_ron C Programming 17 05-07-2006 12:22 PM
Random Question Assign Program mikeprogram C++ Programming 6 11-17-2005 10:04 PM
Simple question about pausing program Noid C Programming 14 04-02-2005 09:46 AM
Can someone help me understand this example program Guti14 C Programming 6 09-06-2004 12:19 PM
Have You Got A program To Match Question. Unregistered C Programming 10 06-01-2002 03:50 PM


All times are GMT -6. The time now is 04:43 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22