This schoolyear I'll be learning C++ at school, and yesterday i received my books wich i'll be using and because i was a bit curious i already started to read in it and eventually i was asked to make a simple program that will caculate your annual salary.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
const int MONTH_YEAR = 12; // 12 month in a year
int salary; // monthly salary
cout << "Typ in your salary" << endl;
salary = cin.get();
int annualSalary = salary * MONTH_YEAR;
cout << "Your annual salary is " << annualSalary << " euro" << endl;
system("PAUSE");
return 0;
}
I think the code is pretty clear: You'll be asked to give a salary lets say 4000, then it give you your annual salary by multiplying your salary with 12 (MONTH_YEAR) but 4000 * 12 = 48000 and not 624 like i get
i'm assuming it has something to do with cin.get() though in the book they were not really clear about what it did (remembering the value i gave salary i think)