vendredi 12 février 2021

Create a program with Arrays and a for counter that consists of a question and answer contest [closed]

THIS IS FOR SCHOOL My teacher has told us to do this and I don't know how:

Create a program with Arrays and a for counter that consists of a question and answer contest.

For it: You will have to create two Arrays, one with the questions and the other one with the answers. (Be careful with the type) A variable to enter the answers given by the user. You must use an IF-ELSE so that when the answer is correct, write on the screen "Correct answer" or when it is incorrect "Incorrect answer". For each correct answer, 50 points will be added and for each incorrect answer, 25 will be subtracted. At the end of the game, if the points are greater than 50, there will be a message saying congratulations and if they are less than 50, the message will be "Better luck next time".

//Práctica 6.17
#include <iostream>
#include <cmath>

using namespace std;
int main()
{
   string preguntas[6] =
           { "¿Que planeta es conocido como “planeta rojo”?",
             "¿Quien escribio el famoso libro Don Quijote de la Mancha?",
             "¿Cual es la central electrica de la celula?",
             "¿Como se denomina el fenomeno semantico que consiste en que una misma palabra tiene varios significados?",
             "¿Cual es el pais mas grande del mundo?",
             0 };
   for (int i = 0; i < 5; i++)
   {
       string respuestas[6] = { "Marte",
                                "Cervantes",
                                "Mitocondria",
                                "Polisemia",
                                "Rusia",
                                0 };
       for (int i = 0; i < 5; i++)
       {
           
           cout << preguntas[i];
           cin >> respuestas[i];
       }
   }
   return 0;
}

Aucun commentaire:

Enregistrer un commentaire