A (Horrible) Beginner Needs Help

This is a discussion on A (Horrible) Beginner Needs Help within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm Dave, the worst person at C++ in the world! I have three questions that will prove how bad ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    2

    A (Horrible) Beginner Needs Help

    Hi, I'm Dave, the worst person at C++ in the world! I have three questions that will prove how bad I am at this!

    1. I'm testing out this whole C++ thing and I'm trying to make a multiple choice thingy. Can someone tell me what's wrong with this? (I didn't read too far on the tutorial.) I'm trying to make it so it goes to the next page thing.
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main (int argc, char *argv[])
    {
      cout << "Hello World!" << endl;
      cout << "Choice One..." << endl; 
      cin.get();
      return 1;
    }
    
    int message (int argc, char *argv[])
    { 
        cout << "Aftermath Of Choice One"  << endl;
        cin.get()
       return 0;
    }
    2. I have no idea what's going on there, it's a startup of Dev-C++, the book I'm learning from doesn't cover this and I don't like reading long things online. Could someone tell me how I make multiple choice things? I don't need a whole tutorial, just how to make the questions.

    3. My uncle asked me what the second + in C++ is, can anyone tell me?

    If this is too much, it's ok. Thanks.
    -Dave

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Well for starters, you don't really need the function that you made there, since this seems to be a fairly simple operation. To make a program with choices you'd do something like this:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
        int userInput;
        
        cout << "How are you?" << endl 
             << "1. Good" << endl
             << "2. Fine" << endl
             << "3. Bad" << endl
             << "> ";
        cin >> userInput;
        
        if (userInput == 1) {
           cout << "\"I'm Good, thank you.\"" << endl;
           }
        else if (userInput == 2) {         
           cout << "\"I'm fine.\"" << endl;
           }
        else if (userInput == 3) {
           cout << "\"I'm feeling bad, sorry.\"" << endl;
           }
        else {
           cout << "\"I'm not sure how I'm feeling.\"" << endl;
           }
           
        system("pause");
        
        return 0;
           
           }
    I'd read more of the tutorials. Read up on Input and if statements. There is no way the book you have doesn't cover those if it is indeed a basic C++ book.

    ...and the second + in C++ essentially means 1. In C++, if you write a variable++ you're saying "variable = variable + 1". So C++ is basially saying it's like the language "C" plus 1.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    2
    Thanks a lot!

  4. #4
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    I don't mean to start an argument, but I thought C++ had a different meaning. In a couple books I've read it says that C++ has 2 pluses because it was an enhanced C language. They called it C with pluses, and eventually it caught on and they just started calling it C++ for short. That's my understanding. If you even care, you could look into it a little further. But I could be wrong, that's just what I've thought for a while.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    I've heard that before, as well, but as far as I know the most common belief of it's origin is "C+1"
    Sent from my iPadŽ

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  2. Problem with extremely beginner exercise
    By Molokai in forum C++ Programming
    Replies: 11
    Last Post: 05-08-2007, 09:05 AM
  3. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 10:21 AM

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