0% found this document useful (1 vote)
294 views2 pages

You Are 10 Years Old. You Are Too Young To Play The Game.: #Include

The document contains 5 coding exercises in C++. Exercise 1 prints two lines of text. Exercise 2 prints an asterisk pattern. Exercise 3 declares and assigns values to variables of different data types and prints them. Exercise 4 prompts the user for their name and prints it. Exercise 5 prompts the user for 3 numbers, prints them in order and reverse order.

Uploaded by

maha hameha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
294 views2 pages

You Are 10 Years Old. You Are Too Young To Play The Game.: #Include

The document contains 5 coding exercises in C++. Exercise 1 prints two lines of text. Exercise 2 prints an asterisk pattern. Exercise 3 declares and assigns values to variables of different data types and prints them. Exercise 4 prompts the user for their name and prints it. Exercise 5 prompts the user for 3 numbers, prints them in order and reverse order.

Uploaded by

maha hameha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 1: Write a C++ program to print the following lines:

You are 10 years old.


You are too young to play the game.
#include <iostream>
using namespace std;
int main ( )
{
cout<<"You are 10 years old."<<endl;
cout<<"You are too young to play the game."<<endl;
return 0;
}

Exercise 2: Write five C++ statements to print the asterisk pattern as


shown below.

*****
*****
*****
*****
*****
cout<<"*****"<<endl;
cout<<"*****"<<endl;
cout<<"*****"<<endl;
cout<<"*****"<<endl;
cout<<"*****"<<endl;
Exercise 3: Write a C++ program to declare two integer , one float
variables and assign 10, 15, and 12.6 to them respectively. It then prints
these values on the screen. #include <iostream>
using namespace std;
int main ( )
{
int a = 10, b = 15;
float c = 12.6;
cout<<a<<endl<<b<<endl<<c<<endl;
return 0;
}

Exercise 4: Write a C++ program to prompt the user to input her/his name
and print this name on the screen, as shown below. The text from
keyboard can be read by using cin>> and to display the text on the screen
you can use cout<<.

Hello Sok! .

#include <iostream>
using namespace std;
int main ( )
{
string name;
cout<<"Enter your name: ";
cin>>name;
cout<<"Hello "<<name<<"!"<<endl;
return 0;

Exercise 5: Write a C++ program to prompt the user to input 3 integer


values and print these values in forward and reversed order, as shown
below

Please enter your 3 numbers: 12 45 78


Your numbers forward:
12
45
78

Your numbers reversed:


78
45
12

#include <iostream>
using namespace std;
int main ( )
{
int num1 , num2 , num3;
cout<<"Please enter your 3 numbers: ";
cin>>num1>>num2>>num3;
cout<<"Your numbers forward: "<<endl;
cout<<num1<<endl<<num2<<endl<<num3<<endl;
cout<<"\nYour numbers reversed: "<<endl;
cout<<num3<<endl<<num2<<endl<<num1<<endl;
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy