Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<time.h>
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- main()
- {
- //make sure no 2 numbers are the same
- srand(time(NULL));
- int randnum,randnum2,oper,ans,computerans,cor,in,loop;
- cout<<"10 question quiz 3 2 1 gooooo\n\n";
- cor=0;
- in=0;
- //the loop will stop after the 10 way around
- for (loop=1; loop<11; loop++)1
- {
- oper=rand() % 3+1;
- //ceching if it is addition
- if (oper=1)
- {
- //setting numbers
- randnum=rand()% 100;
- randnum2=rand()% 100;
- //outputing numbers
- cout<<randnum<<"+"<<randnum2<<" enter your answer -> ";
- cin>>ans;
- //getting the human anser and computer answer
- computerans=randnum+randnum2;
- if(ans==computerans)
- {
- //if you get one right it keeps track
- cor=cor+1;
- }
- else if(ans!=computerans)
- {
- //if you get one wrong it keeps track
- in=in+1;
- }
- }
- //check if qustion is subraction
- else if (oper=2)
- {
- randnum=rand()% 100;
- randnum2=rand()% 100;
- cout<<randnum<<"-"<<randnum2<<" enter your answer -> ";
- cin>>ans;
- computerans=randnum-randnum2;
- if(ans==computerans)
- {
- cor=cor+1;
- }
- else if(ans!=computerans)
- {
- in=in+1;
- }
- }
- //check if its multipication
- else if (oper=3)
- {
- randnum=rand()% 100;
- randnum2=rand()% 100;
- cout<<randnum<<"X"<<randnum2<<" enter your answer -> ";
- cin>>ans;
- computerans=randnum*randnum2;
- if(ans==computerans)
- {
- cor=cor+1;
- }
- else if(ans!=computerans)
- {
- in=in+1;
- }
- }
- //check if its divison
- else if (oper=4)
- {
- randnum=rand()% 100;
- randnum2=rand()% 100;
- cout<<randnum<<"/"<<randnum2<<" enter your answer -> ";
- cin>>ans;
- computerans=randnum/randnum2;
- if(ans==computerans)
- {
- cor=cor+1;
- }
- else if(ans!=computerans)
- {
- in=in+1;
- }
- }
- }
- cout<<"\n\n\n\n\nyou have finished you got"<<cor<<" correct and "<<in<<" incorrect";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement