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

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

Ans.

#include<iostream.h>

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

void main()

{

int totdays,years,weeks,days,num1;

clrscr();//for clear screen

cout<<“\n Enter total number of days: “;

cin>>totdays;

years=totdays/365;

num1=totdays%365;

weeks=num1/7;

days=num1%7;

cout<<“\n Years = “<<years<<“, Weeks = “<<weeks<<“, Days = “<<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 *

31 Views
%d bloggers like this: