Answers for "age in days in c++"

C++
0

age in days in c++

#include<iostream>
using namespace std;

int main()
{
	int n, y = 0, m = 0, d = 0;
	cin >> n;
	
		while(n >= 365)
		{
			y++;
			n -= 365;
		}
		cout << y << " yearsn";
		while(n >= 30)
		{
			m++;
			n -= 30;
		}
		cout << m << " monthsn";
		if(n < 30)
		{
			d += n;
		}
	    cout << d << " daysn";

	return 0;
}
Posted by: Guest on February-10-2022

Browse Popular Code Answers by Language