time dependent program

This is a discussion on time dependent program within the C Programming forums, part of the General Programming Boards category; Hey friends. . .
I wanna make a program in which a ques. Would ask to the person who run ...

time dependent program

Hey friends. . .
I wanna make a program in which a ques. Would ask to the person who run this program. . .after putting the ques. A time of 10 seconds will appear and if the person can not answer the ques. Than the just next loop won't execute. . .how can i do this?

If I understand this correctly, you want a program to:
- ask the user a question
- count down from 10 seconds
- if they cannot answer the question (or, I assume, answer it wrong) then the next loop won't be executed.

This was kind of fun to put together. The trick you're looking for, I suspect, is a way to monitor for user input (to answer the question) but if no user input is present, to continue executing the program (to count down the timer).

If so, then this can be accomplished with the "kbhit()" function. The "Sleep()" function is used to delay one second, and the count down is decreased by one. An argument of 1000 is passed to the "Sleep()" function (1000 milliseconds = 1 second).

If the time runs out, the SECOND LOOP won't execute. If the user enters a guess, the countdown is skipped and, only if the answer is correct, the SECOND LOOP will execute.

I'm glad you enjoyed writting the OP's program for him... but how much do you think he learned from that?
Did you help him become a better programmer or did you simply make him more reliant upon scoop and poop coding?

My apologies. I suppose in my eagerness to assist, I was overly helpful. I thought it would be clearer for the OP to see the function used in a functional program, and they could break it down to apply it to their own program, as my example was overly-simplied to illustrate the concept.

I'll try to exercise more discretion in the future, though. Criticism accepted.

My apologies. I suppose in my eagerness to assist, I was overly helpful. I thought it would be clearer for the OP to see the function used in a functional program, and they could break it down to apply it to their own program, as my example was overly-simplied to illustrate the concept.

I'll try to exercise more discretion in the future, though. Criticism accepted.

Good stuff... I didn't mean to be harsh but we do have to realize that handing out working examples of entire programs both violates the board's Homework policy and fails to actually help the questioner. Most often they just copy and paste (scoop and poop) the code into their own IDE, compile it to make sure it works... then hand it in. A better tactic is the one most here use... get them to post their attempts so far --"post your code..."-- and help them fix it, even if we see a far simpler and easier way to do it. If they do the work with hints from us, we know their brain is engaged far enough to try to think the problem through.

Pay attention to Salem, Adak, Quzah and a few others... they are all good teachers.