C++ Programs Examples
We can take input and output from user very easily. For input we use cin>> and for output we use cout<<.
Assignment:
Write a code/program that takes age of the user as input and print out "You are age years old". For example if user enter his age 19 then your program should print "You are 19 years old".
Dry Run:
What is your age?
19
You are 19 years old.
Think about this program and try to do it by yourself. Otherwise, if you feel any difficulty you can check the solution program below.
#include<iostream>
using namespace std;
void main()
{
int age=0;
cout<<"What is your age?"<<endl;
cin>>age;
cout<<"You are "<<age<<" years old."<<endl;
system("pause");
}
Feel free to ask or comment something!
Comments
Post a Comment
Feel free to comment or ask something related to games.