0
How do I separate the different if statements so that it only runs one?
#include <iostream> using namespace std; int main() { int r; cout<< " The scenario is...\n Katsumoto just died and Nathen Algren is standing before the emperor.\n"; cout<< "in said scenario, on a scale of 1 to 10 how would you rate your emotional pain.\n"; cin>> r; if(r> 2||r<6){ cout<< "you are deeply saddened."; } if (r> 5||r<9){ cout<< "you are heart broken."; } if (r> 8||r<11){ cout<< "you are a drama Queen."; } if (r> -1||r<3){ cout<< "you are nigh on being a sociopath."; } return 0; }
4 ответов
+ 6
use if-else-if
if(condition)
{
//code
}
else if(condition)
{
//code
}
else
{
//code
}
0
use the 'switch' command to break them into cases. This will olny let one run.
0
Maybe you need the else keyword
0
Thank you all, I am glad I have such a great online community to help me learn how to program :). May The Lord Jesus Christ be with you always, and may his love reign supreme in you lives.~B.J.Burks