Mar 29, 2015 at 12:20pm UTC
Please help me to solve the C++ problem to find out
the difference between 2 hours???(hh:min)
for example:
hour 1 : 2:59
hour 2 : 1:29
the difference is 1:30 hrs.
can you make this program?????
Mar 29, 2015 at 12:23pm UTC
could you show us what you did?
Mar 29, 2015 at 12:33pm UTC
I am a neophyte to Programming world...
#include<iostream>
using namespace std;
int main()
{
int Ot, Ct;
cout<<"Enter the Opening time: ";
cin>>Ot;
cout<<"\nEnter the Closing time: ";
cin>>Ct;
cout<<"\nThe difference is "<< Ct- Ot;
return 0;
}
Mar 29, 2015 at 12:40pm UTC
take two variables for a time (for an hour and for a minute).. multiply hour by 60 to get minute and add it to minute.
Do this for second and then subtract and take the division and remainder(mod) and show it.....
Try this If you have doubt feel free to ask it :D
btw please use code tags....
Last edited on Mar 29, 2015 at 12:40pm UTC
Mar 29, 2015 at 12:43pm UTC
cout<<"\nThe difference is " << Ct- Ot; // should be Ot - Ct