C program to convert a given number of days into years, weeks and days.

Q37. Write a C program to convert a given number of days into years, weeks and days.

Ans.

#include<stdio.h>

#include<conio.h>  //for clrscr()

void main()

{

int totdays,years,weeks,days,num1;

clrscr();//for clear screen

printf(“\n Enter total number of days: “);

scanf(“%d”,&totdays);

years=totdays/365;

num1=totdays%365;

weeks=num1/7;

days=num1%7;

printf(“\n Years = %d, Weeks = %d, Days = %d”,years,weeks,days);

}

 

Output

Enter total number of days: 5678

Years = 15, Weeks = 29, Days = 0

Leave a Reply

Your email address will not be published. Required fields are marked *

94 Views
%d bloggers like this: