So my homework is to edit this code. I need to make it so that the player can have limited tries for ex. the player can only have 3 tries, if he fails the game finishes. But in this code one has unlimited tries, so if someone has the time can you please edit my code and help me i am a total beginner in programming and i am stuck on this code for days. So here is the code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
int a=3;
int b=10;
int c;
int d;
int tries=3;
srand(time(0));
c = rand()%(b-a+1)+a;
cout << "I've got a number between " <<a<<"and"<<b<<endl;
do{
cout<<"Gues the number:";
cin>>d;
if(c==d){
cout<<"well done!"<<endl;
} else{
if(c<d){
cout<<"the number is smaller"<<endl;
}else{
cout<<"the number is greater"<<endl;
}
}
} while
(c!=d);
return 0;
}
Please use code blocks from the format toolbox on the right <>
At the moment all our mind readers are busy on other projects so it would be a great idea if you would do the format thing, but also tell us what your program is doing that isn't what you want and why.
Sample output or full error list with line numbers makes it so much easier.
PS if your homework is to actually edit the code which was given to you are actually then in the paid consulting regime not free advice and assistance.