Programming Examples

Program to Convert Days into Month, Week and Days Format


Write a program to input number of days from user and display it, Month, Week and Days format. (consider 30days = 1 month)

For Example:

input is : 50 days

output is: 1 month, 2 week and 6 days.

Solution

#include<stdio.h>
int main()
{
	int days,week,month;
	printf("Enter the Number of Days : ");
	scanf("%d",&days);
	month=days/30;
	week=(days%30)/7;
	days=(days%30)%7;
	printf("%d month, %d week and %d days",month,week,days);
	return 0;
}
Output


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz