hi,
as you can see when the value 'a' is to be entered we have to press enter with it too, is there anyway that it can happen by just entering the digit and not pressing enter after it.
:eek:
# include <iostream.h>
# include <conio.h>
# include <dos.h>
# include <stdlib.h>
# include <time.h>
void main()
{
clrscr();
int reflex;
int a,ran;
cout<<"Press enter to alculate your reflex action";
cout<<"When the test starts press enter";
cout<<"A number will be displayed [0-9] you need to type the number\n";
cout<<"to see your result";
getch();
clrscr();
cout<<"3";
delay(1000);
clrscr();
cout<<"2";
delay(1000);
clrscr();
cout<<"1";
delay(1000);
clrscr();
randomize();
ran=random(9)+1;
cout<<"Enter the number "<<ran<<endl;
clock_t start, end;
start = clock();
cin>>a;
end = clock();
clrscr();
//cout<<(end - start) / (CLK_TCK);
reflex=(end - start)*1000/ (CLK_TCK);
cout<<"\n\n\n";
if (ran==a)
{
cout<<"Your reflex action = "<<reflex;
}
else
{
cout<<"Wrong value entered";
}
getch();
}