| Tester84 (14) | |
| Needing help with a beginner program here. First class I've had on C++ and I'm having some trouble with some if statements and else if statements. If someone can just supply me with a starting point I think I can pretty much figure the rest out. Problem: User inputs a value of 1-365 and a program outputs which month that day will fall in. Ex input day 28 output January. Thanks | |
|
|
|
| mcleano (922) | |
| Everything you'll need you'll find here: http://www.cplusplus.com/doc/tutorial/control/ | |
|
|
|
| Tester84 (14) | |
|
I've looked thru that a good bit and I'm still having problems when I'm going to build. Does this look anything near what it needs to be? #include <iostream> using namespace std; int main () { int day; cout << "Enter a day in the range of 1-365, for ex 248." << endl; cin >> day ; if (day <= 31) cout << "January!"; else if (day >= 32, day <= 59) cout << "February!"; return 0; } | |
|
|
|
| nemesiscplusplus (32) | |||
|
i think you forgot to put a cin.get() in your statement. And when you are putting an "if else statement", do not forget to put an else on it.. By the way, here is the code.
Best regards, nemesis | |||
|
Last edited on
|
|||
| Tester84 (14) | |
| Thanks man! that fixed it! | |
|
|
|
| jsmith (5804) | |||
What is this supposed to do?
| |||
|
|
|||
| herbert1910 (48) | |||
your , is probably supposed to be a &&(logical and). i like your use of exclamation points!i had no idea we could put a series of non-declarative stuff inside and if():
how new school! | |||
|
|
|||