What am I doing wrong?

Apr 10, 2009 at 7:41pm
I am having trouble with the if statment. I need to make 1 to 100 available for two numbers to be entered and the largest number shown as. I also don't know what to put between the programs to keep them seperated. Any help would be greatly appreciated. I have to use the if statments for the numbers.



#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{

int num1;
int num2;
int num3;
int num4;

//numbers to see which one is larger

if (num3 > num4)
cout << "The larger number is " << num3<< endl;
else if (num3 > num4)
cout << "the larger number is " << num4 << endl;
else
cout << "Both numbers are equal." << endl;



//enter a number for the month. This part works.
cout << "Enter a number between 1 and 12 to see the month.";
cin >> num1;

cout << "The number you entered is " << num1;

switch(num1)
{
case 1:
cout << " Janrary";
break;
case 2:
cout << " February";
break;
case 3:
cout << " March";
break;
case 4:
cout << " April";
break;
case 5:
cout << " May";
break;
case 6:
cout << " June";
break;
case 7:
cout << " July";
break;
case 8:
cout << " August";
break;
case 9:
cout << " September";
break;
case 10:
cout << " October";
break;
case 11:
cout << " November";
break;
case 12:
cout << " December";
break;
default:
cout << "That month is invalid.";
break;


}
return 0;
}
Apr 10, 2009 at 7:51pm
You didn't take input for the numbers, and you're using the same comparison twice.
Topic archived. No new replies allowed.