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
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
The following is a C program to convert days to months and days -
Live demonstration
#includemain (){ int months, days ; printf("Enter days ") ; scanf("%d", &days) ; months = days / 30 ; days = days % 30 ; printf("Months = %d Days = %d", months, days) ; }
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
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!