Answer-
Your code is here-
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- main() {
- int max;
- int a,b;
- int sum=0;
- max = 6; //set the upper bound to generate the random
number
- srand(time(0));
- a=rand()%max +1; //genrate the number 1 to
6
- b=rand()%max +1;
- cout << "The random number is: "<<a;
//display first genrate number
- cout<<"\n";
- cout << "The random number is: "<<b;
////display second genrate number
- sum=a+b;
- cout<<"\n"<< "sum="<<sum; //display
sum
- if(sum<5 || 12<sum) //condition sum is less than
5 or greater than 12
- {
- cout<<"\n"<<"you win";
- }
- else
- {
- cout<<"\n"<<"you lose";
- }
- }
screenshot of running program and output-
Note- Please do upvote, if any problem then comment in
box sure I will help.