Write a program which takes your age as an input and output of your program should b like this
You are 24 years old
One year ago,you were 23
In one year you will be 25
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
//prompt the user to enter his/her age
int age;
cout<<"\nEnter your age: ";
cin>>age;
cout<<"\nYou are "<<age<<" years old"<<endl;
cout<<"\nOne year ago, you were "<<(age-1)<<endl;
cout<<"\nIn One year you will be "<<(age+1)<<endl;
return 0;
}
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment