If : give the program an option
#include <iostream>
int main()
{
using namespace std;
int var = 16;
if (var < 30) //if it's false not gonna run the statement
{
cout <<"hello" <<endl; //if true, run this line and move to the next line
}else if(...)
{
}else
{
}
return 0;
}
int main()
{
using namespace std;
int answer;
cout<<"how old.."<<endl;
do{cin >> answer;
if(answer>21)
{
cout<<"too high"<<endl;
}else if{
//for multiple choices
cout<<"too low"<<endl;
}else
{
cout<<"correct"<<endl;
}}while(answer!=21);
}
//very simple multiple options for C++
'Computer General > C++ development from the beginning' 카테고리의 다른 글
Switch statement (0) | 2014.12.16 |
---|---|
Logical OR operator (0) | 2014.12.16 |
Address Operator & Pointer (0) | 2014.12.12 |
Beginning Loop (0) | 2014.12.12 |
Beginning Arrays (0) | 2014.12.12 |