Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,208,590 members, 8,003,054 topics. Date: Friday, 15 November 2024 at 06:01 AM |
Nairaland Forum / Science/Technology / Programming / Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language (579 Views)
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)
Programming Challenge: Adding Time 12h:59m + 20h:53 In Your Programming Language by CodingSoft: 1:49pm 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: 6:51pm 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: 7:13pm On Jan 26, 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: 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: 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 1 Like |
(1) (Reply)
Why Pitch N Hire Best For Permanent Staffing Agency? / Why Bug Bounty Hunting Program Is Urgently Needed In Nigeria / Create A Todo App With React, Node JS And Mysql Using Sequelize And Pagination
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 21 |