Random Math question
Im making a program that asks a math question, how do i make it so that the person who answers only gets 5 seconds?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <iostream>
#include <unistd.h>
#include <fstream>
#include <time.h>
#include <conio.h>
#include <windows.h>
#include <stdio.h>
#include <dos.h>
#include <thread>
#include<chrono>
using namespace std;
class thread;
int main(){
system("COLOR B");
string name;
cout<<"What is your Name?"<<endl;
cin>>name;
int one, two, answer;
srand(time(NULL));
one = rand() % 500 + 1;
two = rand() % 500 + 1;
cout<<"What is "<<one<<" plus "<<two<<"?"<<endl;
std::cin >>answer;
if(answer==one+two)
{
cout<<"Good job "<<name<<"!"<<endl;
}
else{std::cout<<"You suck "<<name<<"!"<<endl;}
return 0;
}
|
Topic archived. No new replies allowed.