Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020068
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:10:57+00:00 2026-05-20T10:10:57+00:00

#include <stdio.h> int main(void) { int days, hours, mins; float a, b, c, total,

  • 0
#include <stdio.h>

int main(void)
{
  int days, hours, mins;
  float a, b, c, total, temp, tempA, tempB;

  a = 3.56;
  b = 12.50;
  c = 9.23;
  total = a+b+c;
  days = total / 24;

  temp = total/24 - days;

  hours = temp * 24;

  tempA = temp*24 - hours;

  mins = tempA*60;

  while (hours >= 24)
    {
      hours= hours-24;
      days +=1;
    }
  while  ( mins >= 60)
    {
      mins=mins-60;
      hours +=1;
    }
  printf("days:%d\n", days);
  printf("hours:%d\n", hours);
  printf("mins:%d\n", mins);


  return 0;
}

I wanted to convert decimal hours to real time and I can do it fine but I wanted to increase days hours if the hours is beyond 24 and if mins is beyond 60mins.
the while loop does subtract and it does print out the new value but the hours / days aren’t getting compounded.
It was 1 day 1 hour 77mins
I wanted it to read 1 day 2 hours 17mins
but I’m getting 1 day 1 hour 17 mins.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:10:57+00:00Added an answer on May 20, 2026 at 10:10 am

    Running your program I’m getting:

    days:1
    hours:1
    mins:17
    

    and that’s what I expect considering that total should be 25.29.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include<stdio.h> int main(void) { int a[3] = {1,2,3}; printf(\n\t %u %u %u \t\n,a,&a,&a+1); return
#include <stdio.h> int main(void){ char x [] = hello world.; printf(%s \n, &x[0]); return
#include<stdio.h> int main(void) { int a=5; printf(%d+1,a); } Output: d. I didn't get how
I'm trying simple example - #include <stdio.h> int main(void) { printf(Content-type: text/html\n\n); printf(<html><title>Hello</title><body>\n); printf(Goodbye
#include stdio.h #include conio.h int main(void) { if(printf(ABC)) { } else { printf(XYZ); }
#include<stdio.h> int main(void) { int i=1,j=-1; if((printf(%d,i))<(printf(%d,j))) printf(%d,i); else printf(%d,j); return 0; } As
#include<stdio.h> int main(void) { signed int a=-1; unsigned int b=1; int c= a+b; printf(%d\n,c);
#include<stdio.h> int main(void) { static int i=i++, j=j++, k=k++; printf(i = %d j =
#include <stdio.h> int main(void) { int x = 1000; char *ptr = &x; printf(%d\n,*ptr);
#include <stdio.h> const int str[1000] = {0}; int main(void) { printf(arr is %d\n, str[0]);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.