Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language (749 Views)
| Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op): 1:49pm On Jan 26, 2023*. Modified: 2:33pm On Jan 26, 2023 |
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 ![]() |
| Re: Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft(op): 6:51pm On Jan 26, 2023*. Modified: 7:16pm On Jan 26, 2023 |
TastyFriedPussy: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: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: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): 7:13pm On Jan 26, 2023*. Modified: 5:19am On Apr 04, 2023 |
TastyFriedPussy: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: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: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: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:What coding language do you want to learn? I should be able to put you in the right direction on how to learn it |
Post Your Programming Projects Ideas Here • Buy This Laptop And Start Your Programming Journey • 2019 Google Hash Code Programming Challenge For Professionals In Africa • 2 • 3 • 4
x • WEMA DOLLAR PAYMENT • Do Programmers Find It Hard To Get Jobs/gigs Currently?
