Very basic help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Very basic help

  1. #1
    Join Date
    Apr 2010
    Posts
    60

    Very basic help

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    string name;
    int main()
    
    { 
        cout << "Hello, Please enter your name\n";
        cin >> name;
        cout << "Hello ";
        cout << name; 
        
        system ("PAUSE");
    }
    So the problem is After "Hello (name)" i cannot make the "Press any key to continue" or whatever, move down a line?

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: Very basic help

    The message will appear after all other text on the console. If you want it to appear on a different line, output a newline before calling pause.

  3. #3
    Join Date
    Apr 2010
    Posts
    60

    Re: Very basic help

    Quote Originally Posted by Lindley View Post
    The message will appear after all other text on the console. If you want it to appear on a different line, output a newline before calling pause.
    How do i output a newline?

  4. #4
    Join Date
    Apr 2010
    Posts
    60

    Re: Very basic help

    I did this and it works.

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    string name;
    int main()
    
    { 
        cout << "Hello, Please enter your name\n";
        cin >> name;
        cout << "Hello ";
        cout << name; 
        cout << "\n";
        
        system ("PAUSE");
    }

  5. #5
    Join Date
    Apr 2010
    Posts
    60

    Re: Very basic help

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    string name;
    string answer1;
    int A;
    int B;
    int C;
    int main()
    
    { 
        //This is the Users name
        cout << "Hello, Please enter your name\n";
        cin >> name;
        cout << "Hello ";
        cout << name; 
        cout << "\n";
        
       //Quiz starts here below
    
        cout << "Welcome to this Quiz, You will need to answer using\n";
        cout << " A,B,C Only, Do not write the actuall answer\n";
        
        system("PAUSE");
        system("CLS");
        
        cout << "#1: What year was World War 2 Officially over?\n";
        cout << "A: July 4, 1939\n";
        cout << "B: September 2, 1945\n";
        cout << "C: May 14, 1942\n";
        
    //------- answer below
        
        cin >> answer1;
        if (answer1 == B);
        cout << "Correct, Well done";
        else cout << "Wrong!, The correct answe is B";
        
        
    }
    Con someone help me with this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center