Question

Write a statement or several statements to input your year of birth and display your age on the [lpt] screen when the year is

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include <iostream>

using namespace std;

int main() {

int year; // variable declaration

cout << "Enter uear of birth: ";

cin>>year; // Accept the year

cout<<"Your age in the year 2020 is "<<2020-year<<endl; // print the age in 2020

return 0;

}

Output:

clanq version 6.0.0-lubuntu2 (taqs/RELEASE 600/final Enter uear of birth: 1991 Your age in the year 2020 is 29

Add a comment
Know the answer?
Add Answer to:
Write a statement or several statements to input your year of birth and display your age...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a SIMPLE code in c++ to input a user's age, name, date, month and year...

    Write a SIMPLE code in c++ to input a user's age, name, date, month and year of birth, favorite color and so on. You will then turn around and ask another person the same and do this for 9 people. You will then output these information for these 9 people back to the screen in the same order. Further, add the ages of all these people and output the total to the screen. comment the code

  • Q1: Write a Java program that will display different messages depending on your age. Your program...

    Q1: Write a Java program that will display different messages depending on your age. Your program should ask the user for his/her name and their age in years and give one or more answers from the following ones below: if the age of the user is less than 16, the program should print on the screen “You are not allowed to drive at the moment”. if the age of the user is less than 18, the program should print on...

  • Need to write a program in Visual Studio CLR CONSOL APPLICATION for date of birth ,...

    Need to write a program in Visual Studio CLR CONSOL APPLICATION for date of birth , addition , substraction . After perfoming additon, there should be an statement " do you wish to continue ? Press Yes to continue or E to exit. Once YES is pressed , then substraction followed by date of birth. If exit is presses then the screen should get closed. i have written a program , so please update that #include "stdafx.h" # include <iostream>...

  • Write a c++ program that asks the user for his birth year. If the birth year...

    Write a c++ program that asks the user for his birth year. If the birth year is later than 2000, then the program outputs the string “You were born in the 21st century”. If the birth year is not greater than 2000, then the program enters the else clause of the outer if statement. This clause starts by outputting the string “You were born in” before comparing the birth year to 1950. If the birth year is less than 1950,...

  • Write a C program which creates a template for a structure to store somebody's date of...

    Write a C program which creates a template for a structure to store somebody's date of birth (day, month, and year). Then write a C function that takes two such structure, one which represents the date of birth, and the other today's date, and returns the age of the user in years. Your function can either provide the full year only (integer) or the floating point age (bonus marks). Next, write a C program which asks the user to enter...

  • 27) Write the code that will display an input box with a title or caption of...

    27) Write the code that will display an input box with a title or caption of "EvenOdd" and a prompt message of "Input Your Number". This input is then tested to see if it as odd or even number and an appropriate message is displayed in a label called "IblAnswer". Assume option strict is ON. (4 poinnstr OPfn Str.et O n

  • 1. Write a program that determines the area and perimeter of a square. Your program should...

    1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen. Area of Square = L (squared) Perimeter of Square = 4 * L 2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to...

  • Write a program that prompts the user to input daily rainfalls and display the total and...

    Write a program that prompts the user to input daily rainfalls and display the total and average rainfall. Use a sentinel controlled loop with sentinel value of -1.   Your output values should only have three digits after the decimal point. Test your program with following input data. 0.31 0.0 0.52 0.79 1.15 1.23 0.93 0.0 0.0 -1 The output of the program should be: The total rainfall is : 4.930 The average rainfall is : 0.547 Copy and paste your...

  • Write a Python script that allows a user to input three exam scores. Display a congratulatory...

    Write a Python script that allows a user to input three exam scores. Display a congratulatory message if the average exam score across all three is greater than 95%. Your solution should follow these general steps; Obtain the first exam score from the user in the form score/max Example: 93/100 Obtain the second score Obtain the third score Check that the user provided numbers and compute the average test score Display the average If the average was greater than 95%,...

  • For Java Keyboard Input Lab3 Ask the user for their name. Then display their name to...

    For Java Keyboard Input Lab3 Ask the user for their name. Then display their name to prove that you can recall it. Ask them for their age. Then display that. Finally, ask them for how much they make and display that. You should use the most appropriate data type for each variable. Hello. What is your name? Dennis Hi, Dennis! How old are you? 37 So you're 37, eh? That's not old at all! How much do you make, Dennis?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT