Learning programming from Book "Programming Principles and Practice Using C++"
I'm trying to get statement for such as 01 = January.
I get four errors.
Let me assure you, i'm a newbie! Can someone please explain what's wrong?
An example will greatly help. Thanks!
22,35 [Error] expected ';' before numeric constant
20,2 [Error] 'else' without a previous 'if'
16,19 [Error] expected ')' before numeric constant
16,6 [Error] 'month_number' was not declared in this scope
Do not place semicolons after if or else lines, as that means to do nothing (just a semicolon is an empty statement). You are also:
* Have a strange condition for your if statement - what is this supposed to say?
* Missing a closing parentheses after your if
* Have an extra space on line 22 between month and 1
#include <std_lib_facilities.h>
int main()
{
int month = 0;
std::cout << "Hello, please put in your birthday's month. In number form. \n";
std::cin >> month;
if (01 == month)
cout << "The month of your birthday is: " << "January";
return 0;
}
I would recommend using an array (vector) of strings to store the month names, and/or use a switch statement for getting the proper month name instead of using multiple if/then statements.