samedi 8 avril 2017

Create two dimensional array with a random times table quiz in C++

I'm trying to create two 2D array quiz. The quiz tests the user on a times table from 1 through 10 of the user's choice for instance:(if user chooses number 2). 1x1=2, 1x2=2, 1x3=3, 1x4=4 and so on.... until they answer all 10 questions. Questions are randomly given one after another. After user answers all 10 questions, results are displayed based on the number correct divided by 10. I don't have my random in yet or NULL, only the first table.

#include <cmath>
#include <iostream>
using namespace std;

int main ()
{
//variables
int num, i = 0, j = 0;
    cout << "What times table would you like to review?" << endl;;
    cout << "Please enter a value from 1 to 12 > \n";
    cout << "\n";
    cin >> num;   //ask user for a value from 1 to 12
    cout << endl;

    //create table
    for(int i=0; i<10; i++) //1st for loop for rows
    {
        for (int j=0; j<1; j++) //2nd for loop for columns
        {
            cout << i +1 <<" x "<<num<<" = "<<i * num<<endl;    
        }   
    }
    cout << endl;

return 0;
}




Aucun commentaire:

Enregistrer un commentaire