Programming Help In C

Discussion in 'Programmer's Corner' started by doo20000, Apr 2, 2008.

  1. doo20000

    Thread Starter New Member

    Apr 2, 2008
    1
    0
    hello, all i am new to the site and heard from a friend that it is a very wonderful place to get help. i am stuck with some programming and i really need help. please help me here is the problem :

    I want to write a program of two functions. One is add time function and the other one is minus time function. The main
    function will call add time and minus time function according to the condition in its own. The program should be like this:


    I want to write a program of two functions. One is add time function and the other one is minus time function. The main
    function will call add time and minus time function according to the condition in its own. The program should be like this: (attached file)
     
  2. Colin Mac

    Member

    Mar 11, 2008
    18
    0
    Do you understand, how functions take parameters and return values. More like this:

    Code ( (Unknown Language)):
    1. #include <stdio.h>
    2.  
    3. int addtime(int btime )
    4. {
    5.  
    6.   btime = btime + 10;
    7.   return btime;
    8.  
    9. }
    10.  
    11.  
    12. int minustime(int btime)
    13. {
    14.  
    15.   btime = btime - 10;
    16.   return btime;
    17.  
    18. }
    19.  
    20.  
    21. int main(void)
    22. {
    23.   int begintime = 10;
    24.  
    25.   while(1)
    26.    {
    27.       if (something > something)
    28.       {
    29.       begintime = addtime (begintime);   //i want to add 10 ms to beginetime
    30.       }
    31.  
    32.       if (something < something)
    33.       {
    34.       begintime = minustime (begintime);    //i want to minuse 10 ms from beginetime
    35.       }
    36.                
    37.    }  
    38.      return 0;
    39. }
     
Loading...