i want program

user give date and year of his/her birth and program tells how old is he or she ... thx
this looks like it should be in the jobs area. Are you asking someone to write code for you for money?

If you need *help* you have to show what you have so far so we can *help* with it.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <cctype>
#include <limits>

int main()
{
   std::cout << "Do you want someone to do all the work for you? ";
   char answer { };
   std::cin >> answer;

   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

   if (std::toupper(answer) == 'Y' ) { std::cout << "Post it in the Jobs section.\n"; }

   else { std::cout << "Show what you have coded so far.\n"; }

   std::cout << "Good luck.\n";
}
I was inspired by Ganado to help out. if your endian is different from mine you will have to correct the integers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

int main()
{
	auto t = time(0);
	auto s = (string)ctime(&t);
	auto i = stoi(s.substr(s.length()-6,s.length()));
	int bdy;
	cout << "enter your bd year>";
	cin >> bdy;
	uint64_t x[] = {0X6820756f79206669, 0X2064616820657661, 0X2064622072756f79, 0X6165792073696874, 
	0X726120756f792072, 0X2020202020203a65, 0X756f792065736c65, 0X0020203a65726120 };
	sprintf((char*)(&x[5]) +2,"%i", i-- -bdy);
	*((char*)(&x[5]) +4) = ' ';
	sprintf((char*)(&x[7]) +6,"%i", i-bdy);
	cout << (char*)x << endl;	
}

edit, fixed... was off by 1 year because while testing all the offsets I forgot to test the actual progam...
output:
enter your bd year>1950
if you have had your bd this year you are:69    else you are: 68
Last edited on
Topic archived. No new replies allowed.