mercredi 11 novembre 2020

Repeating a question when answer is wrong

So I basically have to create a small quiz however I'm unsure on how i would re ask the question I would use when the answer is wrong. I believe its a loop but I'm lost on which one. This is what I have so far

#include <iostream>
using std::cin;
using std::cout;

int main() {
  std::string answer;

  cout << "Is K before T in the alphabet ?";

  cin >> answer;

  if (answer == "y") {
    cout << "Well done!";
  }

  else {
    cout << "Try again";
  }

Aucun commentaire:

Enregistrer un commentaire