You are missing the parenthesis.
if (carrots2 == 8)
Here's the code:
i get these errors:Code:#include <iostream> int main() { using namespace std; int carrots; cout << "How many carrots do you have?" << endl; cin >> carrots; //User input cin.get(); cout << "Here are two more. " << endl; carrots = carrots + 2; cout << "How many carrots do you have now?" << endl; int carrots2; cin >> carrots2; cin.get(); if carrots2 == 8 cout << "That's correct" << endl; else cout << "That's incorrect" << endl; cin.get(); return 0; }
error C2061: syntax error : identifier 'carrots2'
error C2181: illegal else without matching if
You are missing the parenthesis.
if (carrots2 == 8)
- Gone; this is another shit forum with children as administrators. Not worth contributing to.
Nissen1502 is back (07-16-2013)
Thanks, also fixed my code because it was incorrect, here it is (im proud because it was the first code i made on my own and not copied from the book im reading)
Code:#include <iostream> int main() { using namespace std; int carrots; cout << "How many carrots do you have?" << endl; cin >> carrots; //User input cin.get(); cout << "Here are two more. " << endl; carrots = carrots + 2; cout << "How many carrots do you have now?" << endl; int carrots2; cin >> carrots2; cin.get(); if (carrots2 == carrots) cout << "That's correct" << endl; else cout << "That's incorrect" << endl; cin.get(); return 0; }
Yea, Nice Programming
I do not use any type of messenger outside of MPGH.
Inactive but you can reach me through VM/PM.
Nissen1502 is back (07-16-2013)
you forgot to put parenthesis in line 18
or change the if (carrots2 == 8) to ->> if (carrots2 == carrots)
Nissen1502 is back (07-17-2013)
Here's a little tip, try putting "using namespace std;" outside of the main function, because when you'll use more than one function, it'll be more efficient to declare it once than in every single function.
Nissen1502 is back (07-24-2013)