Ok well I'm fairly new to c++ but i've got the hang of it, unfortunately im having some troubles/questions. Recently whenever I write an input and then output it, if the input wasn't entered as a number then i would just get a long number like -156846216 or 654616586 or something. The other question i have is about running multiple things in one integer like so
1 2 3 4 5 6 7 8 9 10 11 12
int main()
{
int a, b, c;
cout << "Enter your name: ";
cin >> a;
cout << "Now enter your birthyear";
cin >> b;
cout << "and your favorite number";
cin >> c;
cout << "Hello " << a << ", you turn " << 2010-b << " this year and your favorite number is " << c << endl;
return 0
}
whenever I do this and run it it will let you enter in the first int but then autofills the rest with long numbers and ends the script...help meeeee
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string a;
int b;
double c;
cout << "Enter your name: ";
cin >> a;
cout << "Now enter your birthyear";
cin >> b;
cout << "and your favorite number";
cin >> c;
cout << "Hello " << a << ", you turn " << 2010-b << " this year and your favorite number is " << c << endl;
return 0;
}
and i dont think you have to include <string> in the header..just tested it and it works without it..