Erm... Im beginning to program today and i was just trying to make something very simple. This is probably a very simple and stupid error but help is appreciated. Also any extra tips are welcomed. Thank you guys!
#include <iostream>
// Program will ask for two numbers and add them together//
int main ()
{
std:: cout << "Hello, fellow human being. Please choose a number!/n";
int a;
std:: cout << "Choose one more, pretty please!/n";
int b;
std:: cout << "This is the sum of both your numbers:/n" >> int c >> int a + int b;
return 0;
}
LIne 10 Col 61 [Error] expected primary-expression before 'int'
Initialize your variables first, then code...
Once you initialize them, you don't have to do it again within that scope.
Remove the "int " from the "int c", "int a" and "int b" from your last cout statement, just use a,b, and c
cout is for writing to the screen, use cin to get the numbers you want.
learn to use code tags when posting please.
1 2 3 4 5 6 7 8 9
int main ()
{
int a,b,c=0;
std:: cout << "Hello, fellow human being. Please choose a number!/n";
std:: cout << "Choose one more, pretty please!/n";
std:: cout << "This is the sum of both your numbers:/n" << a + b;
return 0;
}
or (if you want this to function)
1 2 3 4 5 6 7 8 9 10 11 12 13
int main ()
{
int a,b,c=0;
std:: cout << "Hello, fellow human being. Please choose a number!\n";
std :: cin >> a;
std:: cout << "Choose one more, pretty please!\n";
std :: cin >> b;
c=a+b;
std:: cout << "This is the sum of both your numbers:\n" << c;
return 0;
}