0

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

Edited by pyTony: fixed formating

3
Contributors
5
Replies
6
Views
11 Years
Discussion Span
Last Post by Dave Sinkula
0

>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';
0

>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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.