₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,944 members, 8,428,748 topics. Date: Wednesday, 17 June 2026 at 10:09 PM

Toggle theme

Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingProgramming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language (756 Views)

1 Reply (Go Down)

Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op):
Add hours and minutes 12h:59m + 20h:53m in your programming language and give the result in hours and minutes like this: 33h:52m
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by TastyFriedPussy: 6:30pm On Jan 26, 2023
done!!
only god knows why NL wount let me post pictures

c++
#include <iostream>
using namespace std;
int main() {

int h1;
int m1;
int h2;
int m2;
int h3;
int m3;
cin>>h1;
cin>>m1;
cin>>h2;
cin>>m2;
h3=h1+h2;
m3=m1+m2;

for(int i=0;i<=m3;i++){
if(m3>59){
m3-=59;
h3+=1;
}
}
cout<<h3<< ":" <<m3;
return 0;
}

now if you will excuse me, i have some geometry to go and study tongue
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op):
TastyFriedPussy:
done!!
only god knows why NL wount let me post pictures

c++
#include <iostream>
using namespace std;
int main() {

int h1;
int m1;
int h2;
int m2;
int h3;
int m3;
cin>>h1;
cin>>m1;
cin>>h2;
cin>>m2;
h3=h1+h2;
m3=m1+m2;

for(int i=0;i<=m3;i++){
if(m3>59){
m3-=59;
h3+=1;
}
}
cout<<h3<< ":" <<m3;
return 0;
}

now if you will excuse me, i have some geometry to go and study tongue
Updated

Sorry this online compiler https://www.programiz.com/cpp-programming/online-compiler/ is not doing the right thing.
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by TastyFriedPussy: 6:56pm On Jan 26, 2023
CodingSoft:
Good try, but I ran your code on this online compiler https://www.programiz.com/cpp-programming/online-compiler/ and I got the result in the image.

The result should be: 33h:52m
work fine in my terminal. i don't know why it's not working for you.
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by TastyFriedPussy: 7:02pm On Jan 26, 2023
CodingSoft:
Good try, but I ran your code on this online compiler https://www.programiz.com/cpp-programming/online-compiler/ and I got the result in the image.

The result should be: 33h:52m when you add this two hours and minutes 12h:59m + 20h:53m
make sure you delete or clear everything on the online compiler first before you paste my code..


#include <iostream>
using namespace std;
int main() {

int h1;
int m1;
int h2;
int m2;
int h3;
int m3;
cin>>h1;
cin>>m1;
cin>>h2;
cin>>m2;
h3=h1+h2;
m3=m1+m2;

for(int i=0;i<=m3;i++){
if(m3>59){
m3-=59;
h3+=1;
}
}
cout<<h3<<"h"<< ":" <<m3<<"m";
return 0;
}
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op):
TastyFriedPussy:
make sure you delete or clear everything on the online compiler first before you paste my code..


#include <iostream>
using namespace std;
int main() {

int h1;
int m1;
int h2;
int m2;
int h3;
int m3;
cin>>h1;
cin>>m1;
cin>>h2;
cin>>m2;
h3=h1+h2;
m3=m1+m2;

for(int i=0;i<=m3;i++){
if(m3>59){
m3-=59;
h3+=1;
}
}
cout<<h3<<"h"<< ":" <<m3<<"m";
return 0;
}
I tried W3Schools online compiler and the result is an error.

The result should be: 33h:52m when you add this two hours and minutes 12h:59m + 20h:53m
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by LikeAking: 8:07pm On Jan 26, 2023
How much u go pay?
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op): 8:13pm On Jan 26, 2023
LikeAking:
How much u go pay?
It's to help programmers develop their skills. I have already implemented it in C# and that's why anyone that wants to try can use any language they prefer.
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by Alusiizizi(m): 9:12am On Jan 27, 2023
TastyFriedPussy:
done!!
only god knows why NL wount let me post pictures

c++
#include <iostream>
using namespace std;
int main() {

int h1;
int m1;
int h2;
int m2;
int h3;
int m3;
cin>>h1;
cin>>m1;
cin>>h2;
cin>>m2;
h3=h1+h2;
m3=m1+m2;

for(int i=0;i<=m3;i++){
if(m3>59){
m3-=59;
h3+=1;
}
}
cout<<h3<< ":" <<m3;
return 0;
}

now if you will excuse me, i have some geometry to go and study tongue
Why do you need the for loop? All you had to do was (m3-(m3 modulo 60))/60 + h3 for hours result and m3 modulo 60 for the minutes result.
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by Nesty1313(m): 5:04am On Apr 04, 2023
CodingSoft:
Add hours and minutes 12h:59m + 20h:53m in your programming language and give the result in hours and minutes like this: 33h:52m
Sir do u teach how to coding, I'm interested to learn
Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op): 2:46pm On Apr 04, 2023
Nesty1313:
Sir do u teach how to coding, I'm interested to learn
What coding language do you want to learn? I should be able to put you in the right direction on how to learn it
1 Reply

Post Your Programming Projects Ideas HereBuy This Laptop And Start Your Programming Journey2019 Google Hash Code Programming Challenge For Professionals In Africa234

I Need A Coder, Someone With Python KnowledgeNeeds A Programing TeacherAll Programming Project-php,java,vb