Home > Backend Development > C++ > Translate the following into Chinese: C program to convert days to months and days

Translate the following into Chinese: C program to convert days to months and days

王林
Release: 2023-08-27 12:57:06
forward
881 people have browsed it

Translate the following into Chinese: C program to convert days to months and days

The user must enter the total number of days. We need to convert the total number of days into months and the remaining days in the next month.

The formula for converting days to months is as follows-

Month=days/30

The logic for finding the remaining days in the next month is as follows-

Days= days 0

Algorithm

Please refer to the algorithm given below to convert days to months and days.

Step 1: Start
Step 2: Declare month and days
Step 3: Read total number of days
Step 4: Compute months
   months=days/30
Step 5: Compute days
   Days= days % 30
Step 6: Print months
Step 7: Print days
Copy after login

Program

The following is a C program to convert days to months and days -

Live demonstration

#include<stdio.h>
main (){
   int months, days ;
   printf("Enter days</p><p>") ;
   scanf("%d", &days) ;
   months = days / 30 ;
   days = days % 30 ;
   printf("Months = %d Days = %d", months, days) ;
}
Copy after login

Output

When When executing the above program, the following results are produced -

Enter days
456
Months = 15 Days = 6
Enter days
145
Months = 4 Days = 25
Copy after login

The above is the detailed content of Translate the following into Chinese: C program to convert days to months and days. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template