Write a program that inputs age in years and display age in days and months.
C++ program that inputs age in years and display age in days and months.
C++ programs:
Source code:
#include<iostream>
/* iostream provides basic
input and output services for C++ programs */
#include<conio.h>
using namespace std;
int main()
// Th execution of program start with the main function
{ // int is the data type
int ageInYears, ageInDays, ageInMonths;
cout<<"Enter your age in years: ";
// cout is used to display the same statement in the output.
cin>>ageInYears;
// Cin used to enter a value by the user.
ageInMonths = ageInYears*12;
cout<<"Your age in months: "<<ageInMonths<<endl;
ageInDays = ageInYears*365;
cout<<"Your age in days :"<<ageInDays<<endl;
return 0;
}
0 Comments