dimanche 13 décembre 2020

What can't I have a randomized number [closed]

This is my first time asking question here and I'm having trouble as to why am I not generating a random number? It always shows the number 6 and 9 only? I'm missing something and I can't find it. Thank you.

#include<iostream>
#include<conio.h>
#include<cmath>
#include<cstdlib>
#include<time.h>
using namespace std;
void multi();
int main()
{   
    char name[20], c;
    cout << "What is your name?" << endl;
    cin >> name;
    do{
    multi();
    cout << endl << "Do you want to continue? (Type only y/n)";
    cin >> c;
    if(c=='N'||c=='n'){
    break;}
    }
    while(1);
       
}
void multi()
{
    int random, randomn, answer, answer1;
    srand(time_t());
    srand(random);
    random = (rand()%11)+1;
    randomn = (rand()%11)+1;
    answer1 = random*randomn;
    system("cls");
    cout << "How much is " << random << " * " << randomn << "?" << endl;
    cin >> answer;
    if(answer!=(random*randomn)){
    cout << "That is incorrect.";
    }
    else if(answer==(random*randomn)){
        cout << "That is correct!" << endl << "Do you want to continue?";
    }
}

EDIT: I thought it showed the image I posted but it didn't. sorry.




Aucun commentaire:

Enregistrer un commentaire