Convert year into months, weeks and days in C Programming

  • Tech Area
  • May 12, 2024



In this tutorial, We will see how to convert year into months, weeks and days in C programming language.

Program to convert year into months, weeks and days

#include<stdio.h>
#include<conio.h>
void main()
{
int y, m, w, d;
clrscr();
printf("Enter year  ");
scanf("%d", &y);
m = y * 12;
w = m * 4;
d = y * 365;
printf("Months = %d\n", m);
printf("Weeks = %d\n", w);
printf("Days = %d\n", d);
getch();
}

Output

Enter year 1
Months = 12
Weeks = 48
Days = 365

The number 1 is entered by the user is stored in the y variable. Years are converted into months using y * 12, weeks using m * 4 and days using y * 365. And, months, weeks & days are stored in variable m, w and d respectively.

printf("Enter year  ");
scanf("%d", &y);
m = y * 12;
w = m * 4;
d = y * 365;

The printf() function is used to print months, weeks and days.

printf("Months = %d\n", m);
printf("Weeks = %d\n", w);
printf("Days = %d\n", d);


Subscribe us via Email

Join 10,000+ subscriber

Subscribe on YouTube