Thread: Problem comparing variables

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    6

    Problem comparing variables

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int num1, num2;
        cout<<"Please enter a number for number one:";
        cin>> num1;
        cout<<"You've entered: "<< num1 <<" for number one.\n";
        cout<<"Please enter a number for number two:";
        cin>> num2;
        cout<<"You've entered: "<< num2 <<" for number two.\n";
        cout<<"Now calculating results....Please wait...\n";
        if (num1 < num2);{
                 cout<< num2 <<"is greater than" << num1 <<"\n";
                 }
        else (num1 > num2);{
                 cout<< num2 <<"is less than" << num1 <<"\n";
                 }
        main();
    }
    When compiling, I get this error,

    Code:
     In function `int main()':
    17 expected primary-expression before "else"
    17 expected `;' before "else"
    I've always had problems with If and Else statements. Anyone wanna help meh out?
    Last edited by Deathscreton; 08-15-2009 at 03:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Problem with global variables
    By DominicTrix in forum C++ Programming
    Replies: 6
    Last Post: 09-08-2004, 01:26 PM
  5. Replies: 4
    Last Post: 10-17-2002, 10:09 PM