❓ 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
  • 353
    Views
  • 1
    Participants
Last reply from:
iamj

Trending Topics

Online now

Members online
1,002
Guests online
1,040
Total visitors
2,042

Forum statistics

Threads
2,276,172
Posts
28,968,039
Members
1,231,153
Latest member
taengdaga
Back
Top