#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
int score = 0;
int user_num, num;
srand(time(0));
for (int i=0; i<10; i++) {
num = random() % 10 + 1;
cout << "Guess number: ";
cin >> user_num;
if (user_num == num) {
cout << "Good" << endl;
score++;
}
else {
cout << "sorry, correct answer is " << num << endl;
}
}
cout << "Final score: " << score << endl;
return 0;
}
Comments
Leave a comment