
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C program to convert days into months and number of days
User has to enter total number of days. We need to convert the total number of days into months and left-over days in coming month.
The formula to convert days into months is as follows −
Month=days/30
The logic to find left-over days for the coming month is as follows −
Days=days %30
Algorithm
Refer an algorithm given below to convert days into months and number of 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
Program
Following is the C program to convert days into months and number of days −
#include<stdio.h> main (){ int months, days ; printf("Enter days\n") ; scanf("%d", &days) ; months = days / 30 ; days = days % 30 ; printf("Months = %d Days = %d", months, days) ; }
Output
When the above program is executed, it produces the following result −
Enter days 456 Months = 15 Days = 6 Enter days 145 Months = 4 Days = 25
- Related Questions & Answers
- Converting days into years months and weeks - JavaScript
- Program to convert given number of days in terms of Years, Weeks and Days in C
- How to get days, months and years between two Java LocalDate?
- Get the last days of all the months in MySQL?
- C# Program to display the number of days in a month
- C++ Program to calculate the number of odd days in given number of years
- Converting seconds into days, hours, minutes and seconds in C++
- Python program to find number of days between two given dates
- How to add number of days to JavaScript Date?
- Find number of days between two given dates in C++
- Number of days in a month in Python
- Finding Number of Days Between Two Dates JavaScript
- Program to find minimum number of days to make m bouquets using Python
- Program to find minimum number of days to eat N oranges in Python
- Get the number of days between current date and date field?
Advertisements