Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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

0 votes
asked Nov 26, 2019 by anonymous

6 Answers

–1 vote
answered Nov 27, 2019 by legend
#include<iostream.h>

using namespace std;

int main()

{

int age;

cout<<"Enter your age :";

cin>>age;

cout<<"Your age is "<<age;

return 0;

}
–1 vote
answered Nov 28, 2019 by Edgar (120 points)
0 votes
answered Nov 29, 2019 by Anvar (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<<"Please enter the following information."<<endl;
 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;
 cout<<"Your age is " <<ans<<"."<<endl;

 
 
    return 0;
}
0 votes
answered Nov 29, 2019 by Noam0509
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
0 votes
answered Dec 3, 2019 by Mahadev (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;
}
0 votes
answered Dec 7, 2019 by anonymous
In python you do this

import UIKit

age= input("Enter your age: ")

print("Your age is "+age)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...