0
TechCake
As per my point of view,...

Example 1h 55m + 1h 50 m
Add 155+155 take 55 + 55 =110 , nCount=0
Now compare it with 60 (if 110 > 60 ) 110 - 60 =50 ++nCoun;
Answer will be (1+1+ ncount)H 50M

Example2:
1h50m + 1h 50m + 1h 50m
=> 50 +50 +50 =150 which is greater than 60 => 150-60 =90 , ncount=1
=> till less than 60 i.e. 90 - 60 =30 , nCount =2
=> So answer will be 1h+1h+1h+2=5h 30m

NOTE: It's slightly diverse from your type of solution ...
0
Mentor
OK, so what's the point of the 155 value if you're going to reckon hours and minutes separately anyway?
0
TechCake
Same thing you are doing as adding 1h55m + 1h55m = 310
for i=1 to numberofoverflow=1

result will be : 3h 50m

Example2 : 1h50m + 1h50m +1h50m = 450
for i=1 to numberofoverflow=2

result = 5h 30m

Now adding 40 in this case or substracting 60 where you have take minute parametere only .
No difference....
0
Mentor
How might you implement that in C?
0
TechCake
Code:
```#include<iostream.h>
#include<malloc.h>

#define uint unsigned int
int main()
{
uint noOfOverFlow=0,reqSum=0,i,hr[3],min[3],minuteSum=0;
for(i=0;i<3;++i)
{
cout<<"Enter "<<i<< " Hour"<<endl;;
cin>>hr[i];
cout<<"Enter "<<i<< " minutes"<<endl;
cin>>min[i];
}
minuteSum=min[0]+min[1]+min[2];
noOfOverFlow = minuteSum/60;
for(i=0;i<3;++i)
reqSum= reqSum+ hr[i]*100+min[i];
cout<<"reqSum"<<reqSum<<endl;
minuteSum=(reqSum)%100;
cout<<"MinuteSum"<<minuteSum<<endl;

for(i=0;i<noOfOverFlow; ++i)
{
minuteSum = minuteSum +40;
}
cout<<"MinuteSum"<<minuteSum<<endl;

cout<<"Finally Sum is"<<((hr[0]+hr[1]+hr[2])+ noOfOverFlow)<<"hr"<<minuteSum%100<<endl;;

return 0;
}```
Output:
Code:
```asadulla ~/temp> g++ test.cc
Enter 0 Hour
1
Enter 0 minutes
50
Enter 1 Hour
1
Enter 1 minutes
50
Enter 2 Hour
1
Enter 2 minutes
50
reqSum450
MinuteSum50
MinuteSum130
Finally Sum is5hr30
Enter 0 Hour
1
Enter 0 minutes
90
Enter 1 Hour
1
Enter 1 minutes
90
Enter 2 Hour
1
Enter 2 minutes
90
reqSum570
MinuteSum70
MinuteSum230
Finally Sum is7hr30```

As i will suggest substraccting 60 is better solution than adding 40....
adding 40 method is better if are calculating manually i.e. writing Competetive examination like CAT, GMAT etc.
0
Mentor
Seems a lot more work than:
Code:
```void go4e_15847()
{
uint noOfOverFlow=0,reqSum=0,i,hr[3],min[3],minuteSum=0;
for(i=0;i<3;++i)
{
cout<<"Enter "<<i<< " Hour"<<endl;;
cin>>hr[i];
cout<<"Enter "<<i<< " minutes"<<endl;
cin>>min[i];
}
minuteSum=min[0]+min[1]+min[2]+(hr[0]+hr[1]+hr[2])*60;
cout<<"Finally sum is "<<(minuteSum/60)<<"h "<<(minuteSum%60)<<"min"<<endl;
}```
0
TechCake
i have already told that ...