#include <iostream>
#include <windows.h>
usingnamespace std;
int main()
{
cout << "Test with variants.\nChoose a,b,c,or d as the answer by typing the coresponding letter.\n";
Sleep(3000);
cout <<"Get ready for the first question.You have 5 seconds to answer\n";
Sleep(5000);
cout<<"Question one:\n What's 48+52?\n";
int timer()
{
int a=5;
while(a>=0)
cout<<a<<","<<--a;
}
cout<<"a=96\n";
cout<<"b=100\n";
cout<<"c=104\n";
cout<<"d=98\n";
int ans1,a,b,c,d;
cin>>ans1;
Sleep(1000);
if(ans1=a)
{
cout<<"Correct,the answer is 96.\n";
}
else
{
cout<<"Wrong.The right answer was 96\n";
}
I would like to make a test where you insert one of the given variants,in 5 seconds.I fail when I try to add the timer.The error is <<a function-definition is not allowed here before '{' token>>
EDIT:Forgot to say that if the time runs out ,the message <<Question skipped>> to appear and to automatically skip to second question.
Line 12: What is this line? Is it an int declaration? A function call? Or a function prototype?
The compiler thinks you're trying to define a nested function, which is not allowed.