111k views
1 vote
Write a C++ program that asks the user to enter his age. The program then should display the age in months:

Enter your age: 29

Your age in months is 384.

User Mollie
by
5.6k points

1 Answer

3 votes

Answer and Explanation:

It's actually pretty easy, keep in mind you need to import the following libraries at the beginning of the code:

#include <iostream>

#include <stdio.h>

#include <math.h>

using namespace std;

int main(){

int age;

int age_m;

cout<<("enter your age");

cin>>age;

age_m=age*12;

cout<<("Your age in months is: ");

cout<<age_m;

}

User Marquis Blount
by
6.5k points