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();
    }

Recommended Answers

All 5 Replies

this program is for tc only

>is there anyway that it can happen by just entering the digit and not pressing enter after it.
Change this:

cin>>a;

To this:

a = getch() - '0';

Thx alot Narue

what does "Kisama wa akan da!" mean?

>what does "Kisama wa akan da!" mean?
You probably don't want to know. ;)

>what does "Kisama wa akan da!" mean?
You probably don't want to know. ;)

Is it anything like one of my favorite quotes from Married... With Children?

... And this is the river the Indians used to call KissYourWhiteAssGoodbye.

:p

[edit]The episode had something to do with whitewater rafting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.