# how i make a programm for "what is my age"

–1 vote
#include<iostream.h>

using namespace std;

int main()

{

int age;

cin>>age;

return 0;

}
–1 vote
answered Nov 28 by (120 points)
answered Nov 29 by (160 points)
#include <iostream>

using namespace std;

#include <iostream>

int main()
{
int pm=9;
int pd=14;
int py=2019;
int bm;
int bd;
int by;
int ans;

cout<<"1. Birth Month"<<endl;
cin>>bm;
cout<<"2. Birth Day"<<endl;
cin>>bd;
cout<<"3. Birth Year"<<endl;
cin>>by;
cout<<"Present Month"<<endl;
cin>>pm;
cout<<"Present Day"<<endl;
cin>>pd;
cout<<"Present Year"<<endl;
cin>>py;
ans=pm-bm;

ans=pm-bm;
ans=pd-bd;
ans=py-by;

return 0;
}
in java you do this:

import java.util.Scanner; //i imported the Scanner
public class Main{ //this is the start of the class
public static void main(String[] args) { //this is the start of the public Main

Scanner sc = new Scanner(System.in); //this is important here i create the scanner

System.out.println("pls enter your age: "); //here i tell him pls enter your name(basic command) ya

int age = sc.nextInt(); //this is also important in here i tell him to enter his age (no Letters) pls

System.out.println("Your age is: " + age); //and here i print the result

} // the end of the public Main thingi
} // here  is the end of the class
answered Dec 3 by (140 points)
This program gives the exact age of the person with automatic comparing the present date and Person DOB.

#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main()
{
int bd, bm,by,ans1,ans2,ans3;
int i,j,k;
int m[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

time_t t = time(NULL);
struct tm tm = *localtime(&t);
printf("Today's date is: %d-%d-%d \n", tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);

printf("Enter the DOB: ");
scanf("%d-%d-%d",&bd, &bm, &by);

i  = tm.tm_mday;
j  = tm.tm_mon + 1;
k = tm.tm_year + 1900;

if (bd > i)
{
i = i + (m[bm - 1]);
j = (j - 1);
}

if (bm > j)
{
k = (k - 1);
j = (j + 12);
}

ans1 = i - bd;
ans2 = j - bm;
ans3 = k - by;

printf("Your present age is: %d year %d months %d days",ans3,ans2,ans1);
return 0;
}