Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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 << " years
";
		while(n >= 30)
		{
			m++;
			n -= 30;
		}
		cout << m << " months
";
		if(n < 30)
		{
			d += n;
		}
	    cout << d << " days
";

	return 0;
}
Source by codejudge.blogspot.com #
 
PREVIOUS NEXT
Tagged: #age #days
ADD COMMENT
Topic
Name
8+5 =