Assignment 01: Single Cout Statement
Assignment 01: Single Cout Statement
Q. No. 1
Write a C++ computer program to write your first name on first line of the console, middle name
on the second line and last name on the third line using a single cout statement. (Use \n after first
name and endl for the next two names.
Example output
My first name is Hafiz
My middle name is Hassaan
My last name is Saeed
Q. No. 2
Write a C++ computer program to express your love for your country. Print “I love Pakistan”
five times on the console in five different lines but using a single cout statement.
Q. No. 3
Write a C++ computer program to print one initialized character variable, one initialized integer
variable and one initialized float variable using three different cout statements but all the
variables should be written in a single line on the console and each variable is separated by a tab
space.
Q. No. 4
Read three float variables in a single cin statement and print all the variables in a single cout
statement separated by tabs.
Q. No. 5
Write a C++ computer program that prints the following message.
My name is “Pakistan” and the people living in ‘Pakistan’ are called \Pakistanis\
Rawalpindi is a \city’ in “Punjab\ and Punjab “is’ a province in Pakistan.
Q. No. 6
Read radius and give area of circle. (∏r2)
Q. No. 7
Read rupee value from the user and give its dollar equivalent. ($1 = PKR 166)
Q. No. 8
Read two integer variables named a and b and print the result of the equation a2 + b2 + 2ab.
Q. No. 9
Read two float variables and print their product as shown in the following sample.
Example output
Enter first float variable: 3.5
Enter second float variable: 2.7
The product of 3.5 and 2.7 is 9.45
Q. No. 10
Read apples and oranges as integer variables and print total fruits.
Example output
Enter apples: 5
Enter oranges: 7
There are 5 ‘apples’ and 7 \oranges\ and total “fruits” are 12
Q. No. 11
Write a program the reads a number from user and tells its equivalent character symbol.
Sample output
Enter a number: 97
97 is the ASCII of “a”