Functions Worksheet Answers


  1. int totsecs(int hours, int minutes, int seconds)
    {
       int total;
       total = ((hours * 60) + minutes) * 60 + seconds;
       return total;
    }
    
    
  2.    int tot = totsecs(2,15,32);
       cout << "Total seconds: " << tot << endl;
    
    
  3. int totsecs(int hours, int minutes)
    {
       int total;
       total = ((hours * 60) + minutes) * 60;
       return total;
    }
    
    
  4.    int tot = totsecs(3,22);
       cout << "Total seconds: " << tot << endl;
    
    
  5. int totsecs(int, int=0, int=0);
    
    int totsecs(int hours, int minutes, int seconds)
    {
       int total;
       total = ((hours * 60) + minutes) * 60 + seconds;
       return total;
    }
    
    
  6.    int tot = totsecs(4);
       int tot = totsecs(4,37);
       int tot = totsecs(4,37,44);
    


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002