hi guys!!
i am wrting a program for a small arithemtic game,it displays two numbers and ask user to enter the sum of these two numbers,the program runs fine but i want to add a countdown timer,i mean time limit for user to answer all 10 questions within 30 seconds.i hav tried everything but dint came up with any idea
it should display the timer and questions.plzz help i am new to programming

here is the code

void addtion()
{
     int firstran,secondran,num1,num2,sum,in1,ans,count=0,right=0,worng=0,score=0;
     cout<<"\t\t\t\tADDTION\n";
                               for(int k=0;k<80;k++)
                              {
                                  cout<<"-";
                                  delay1();
                              }
                              cout<<"\n\nREADY????";
                              delay1();
                              cout<<"\n\nENTER A CHAR WHEN READY.....\n";
                              cin>>in1;
                              system("cls");
                              cout<<"\t\t\t\tLEVEL 1\n";
                              ////print lines----------------------------------
                              for(int i=0;i<80;i++)
                              {
                                  cout<<"-";
                                  delay1();  //delay to print cgar by char
                              }
                              cout<<"\t\t\t\tADDTION\n";
                               for(int k=0;k<80;k++)
                              {
                                  cout<<"-";
                                  delay1();
                              }
                              //////////--------------------------------------
                              cout<<"\nGO!!\n";
                              for(int i=10;i>0;i--)                                                                                                               
                              {
                                      
                                      firstran=random();                                                                                        
                              num1=gennumber(firstran);                          ///generate two random numbers for addtion//////
                              secondran=random2(num1);                           //gennumer generates number within 99 for level 1///
                              num2=gennumber(secondran);
                              count++;
                              sum=num1+num2;
                            cout<<count<<"  ->  "<<num1<<"  +  "<<num2<<"  = ";
                              cin>>ans;
                              
                              if(ans==sum)
                              {
                                    right++;
                                    score=score+10;
                              }
                              else { worng++;}                              
                              }
                              
                              
                              results(right,worng,score);                 ////prints the result to std output///
                              getinfo(score);                             ///get player name and store it in file with scores////
                              viewscores();                               ///read names from the file and display it on std output///
                                      
                              
                              
}

thanx for the reply daviddoria

will it work on DEV C++ ??
i think the program runs only on linux platform

i not able to understand the code :((

Edited 6 Years Ago by debugger09: n/a

thanx for the reply daviddoria

will it work on DEV C++ ??
i think the program runs only on linux platform

i not able to understand the code :((

It's Boost, so you have to download/install it and play around with it. It's not part of the C++ standard, but it should work fine in both Linux and C++. I haven't done much with it. daviddoria linked a particular library within Boost.

http://en.wikipedia.org/wiki/Boost_C%2B%2B_Libraries

i hav used clock() function to sart a countdown timer,program works good
but i want to display the timer at the corner of the screen along with the question
is there any way to run two functions at the same time

Edited 6 Years Ago by debugger09: n/a

i new to this programming stuff,i'm not a advance programmer so it will be too soon to start with multithreading
i need some other idea

anyway thanx nick for replying

This article has been dead for over six months. Start a new discussion instead.