/*************************************************
Military Clock Increment

Write a function 

   void inc(int*);

That increments an int representing a 24-hour
military clock.
*************************************************/
#include <iostream>
using namespace std;

void inc(int*);

/*****************
 ** main()
 *****************/
int main()
{
  // Enter starting time (military) and minutes M
  int T, M;
  cout << "Enter starting time: ";
  cin >> T;
  cout << "Enter number of minutes: ";
  cin >> M;

  // Icrement time by M minutes
  for(int i = 0; i < M; i++)
    inc(&T);
  
  // Write out time (look out for leading 0's)
  cout << "Time is " ;
  if (T < 10)
    cout << "000";
  else if (T < 100)
    cout << "00";
  else if (T < 1000)
    cout << "0";
  cout << T << endl;

  return 0;
}

/*****************
 ** inc - increment
 ** an int as a 24
 ** hour military
 ** clock
 *****************/
void inc(int* pT)
{
  (*pT)++;
  if (*pT % 100 >= 60)
    *pT = (*pT/100 + 1)*100;
  if (*pT == 2401)
    *pT = 1;
}