Multiple Choice Program
Sep 18, 2011 at 8:25pm UTC
Hey!
I've been trying to make a multiple choice program with if and else, but I can't figure out how to do it. This is what my code is so far:
(I'm on a Mac using Xcode if anyone wondering)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include <iostream>
using namespace std;
int yes;
int no;
int number1;
int number2;
int main ()
{
cout << "Want to add?" ;
if (cin==yes);
{
cout << "Enter two nubers." ;
cin >> number1;
cout << "Second number" ;
cin >> number2;
cout << number1 + number2;
}
return 0;
}
Sep 18, 2011 at 8:29pm UTC
You don't know use if/else ?
Sep 18, 2011 at 8:36pm UTC
Here is an example of how to use if and else statements:
1 2 3 4 5 6 7
if (condition)
{
//do stuff
} else
{
//do other stuff
}
-
Code Assassin
Topic archived. No new replies allowed.