Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: remove something from stringstream 
Cpp :: how to pass an array by reference in c++ 
Cpp :: minheap cpp stl 
Cpp :: variadic template in c++ 
Cpp :: ascii allowed in c++ 
Cpp :: c/c++ windows api socket wrappers 
Cpp :: declare empty array in c++ 
Cpp :: C++ detaching threads 
Cpp :: assign one vector to another c++ 
Cpp :: hide window c++ 
Cpp :: c++ define array with values 
Cpp :: executing an opencv c++ code 
Cpp :: compare function in c++ 
Cpp :: find factorial in c++ using class 
Cpp :: std::string substr 
Cpp :: c++ copy constructor 
Cpp :: know what the input data is whether integer or not 
Cpp :: define a type in c++ 
Cpp :: deque 
Cpp :: pragma HLS bracets 
Cpp :: cpp serial print override always in same place 
Cpp :: pointer to value of others file cpp 
Cpp :: how to scan vector in c++ 
Cpp :: c++ graphics online compiler 
Cpp :: error c4001 site:docs.microsoft.com 
Cpp :: true false operator 
Cpp :: progress bar custom color c++ buider 
Cpp :: second smallest element in array using one loop 
Cpp :: what do I return in int main() function c++ 
Cpp :: how to run the code 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =