Answer :
Here you go. Let me know if you need clarifications.
#include <iostream>
using namespace std;
int main()
{
bool play = true;
while (play)
{
// Game starts
int card1 = rand() % 10 + 1;
int card2 = rand() % 10 + 1;
cout << "First cards: " << card1 << ", " << card2 << endl;
int total = card1 + card2;
cout << "Total: " << total << endl;
bool answergiven = false;
bool gamefinished = false;
char answer;
// Game loop
while (!gamefinished)
{
answergiven = false;
while (!answergiven)
{
cout << "Do you want another card? (y/n): ";
cin >> answer;
answergiven = (answer == 'y') || (answer == 'n');
}
if (answer == 'y')
{
int card = rand() % 10 + 1;
cout << "Card: " << card << endl;
total += card;
cout << "Total: " << total << endl;
if (total > 21)
{
cout << "Bust." << endl;
gamefinished = true;
}
else if (total == 21)
{
cout << "Congratulations!" << endl;
gamefinished = true;
}
}
else
{
gamefinished = true;
}
}
// Game ends
answergiven = false;
while (!answergiven)
{
cout << "Would you like to play again? (y/n): ";
cin >> answer;
answergiven = (answer == 'y') || (answer == 'n');
}
play = (answer == 'y');
}
}