❓ Help Bot Only

Sure, here's a simple C program that prompts a user for a number of days and converts that into hours, minutes, and seconds:

C:
#include <stdio.h>

int main()
{
    int days;
    long int hours, minutes, seconds;

    printf("Enter the number of days: ");
    scanf("%d", &days);

    // converting days to hours, minutes and seconds
    hours = days * 24;
    minutes = hours * 60;
    seconds = minutes * 60;

    printf("In %d days there are: \n", days);
    printf("%ld hours \n", hours);
    printf("%ld minutes \n", minutes);
    printf("%ld seconds \n", seconds);

    return 0;
}

In this program, the user is first asked to enter the number of days. This input is stored in the variable 'days'. The program then calculates the equivalent number of hours, minutes, and seconds by multiplying the number of days by 24 (to get hours), the number of hours by 60 (to get minutes), and the number of minutes by 60 (to get seconds). Finally, the program prints out the results.
 
#include <stdio.h>

int main()
{
float day1;
int hour1, min1, sec1;

scanf("%f", &day1);

hour1 = day1 * 24;
min1 = hour1 % 24;
sec1 = min1 % 60;

printf("Hours: %d", hour1);
printf("Minute: %d", min1);
printf("Seconds: %d", sec1);

}

Check

Sure, here's a simple C program that prompts a user for a number of days and converts that into hours, minutes, and seconds:

C:
#include <stdio.h>

int main()
{
    int days;
    long int hours, minutes, seconds;

    printf("Enter the number of days: ");
    scanf("%d", &days);

    // converting days to hours, minutes and seconds
    hours = days * 24;
    minutes = hours * 60;
    seconds = minutes * 60;

    printf("In %d days there are: \n", days);
    printf("%ld hours \n", hours);
    printf("%ld minutes \n", minutes);
    printf("%ld seconds \n", seconds);

    return 0;
}

In this program, the user is first asked to enter the number of days. This input is stored in the variable 'days'. The program then calculates the equivalent number of hours, minutes, and seconds by multiplying the number of days by 24 (to get hours), the number of hours by 60 (to get minutes), and the number of minutes by 60 (to get seconds). Finally, the program prints out the results.
You need to get the remainder. The minute must not exceed 60 and so the seconds.
 

Similar threads

About this Thread

  • 2
    Replies
  • 365
    Views
  • 1
    Participants
Last reply from:
iamj

Trending Topics

Online now

Members online
513
Guests online
3,637
Total visitors
4,150

Forum statistics

Threads
2,310,038
Posts
29,154,186
Members
1,188,807
Latest member
poloko
Back
Top