Egyptian Russian University
Faculty of Artificial intelligence
CS102: Structured Programming st
1 Year
Spring 2024
Sheet #2
Problem 1:
Write a C++ program that read an user’s full name of console input into a
variable, then print “Hi , full name “.
Input: Enter your full name: Kinda Malek
Output: Hi, Kinda Malek
Problem 2:
Write a C++ program that accepts two numbers entered by the user and
computes their Sum, Difference, Product, Quotient and Remainder.
Problem 3: (Lab)
The arithmetic mean of two numbers is the result of dividing their some by
2. The geometric mean of two numbers is the square root of their product.
The harmonic mean of two numbers is the arithmetic mean of their
reciprocals. Write a C++ Program to that takes two floating-point numbers
as inputs and displays these three means.
Problem 4:
In a laboratory, the time of an experiment is measured in seconds. Write a
C++ Program to enter the time in seconds, convert and print out it as a
number of hours, minutes and seconds. Use appropriate format for the
output.
Problem 5: (Lab)
Write a C++ program that asks the user to input the following:
• The number of gallons of gas in the tank
• The fuel efficiency in miles per gallon
• The price of gas per gallon
Then print the cost per 100 miles and how far the car can go with the gas in
the tank.
Note that:
cost per miles = miles / fuel efficiency * gas price
max distance = fuel efficiency * gas tank
Problem 6: (student)
To enter the length (in meters), width (in meters) of a rectangular carpet
and carpet price per square meter. The program should compute and
display its area, perimeter and cost of the carpet. using the following
formula: area = width * height perimeter = 2 * (width + height)
Problem 7: (student)
Write a C++ program that converts the length in feet to centimetres, you
can calculate the length in cm (LCM) by multiplying length in feet (Lft) with
30.
Problem 8: Find The Output:
#include <iostream>
using namespace std;
int main() {
int num1 = 70;
double num2 = 256.783;
char ch = 'A';
cout << num1 << endl; // print integer
cout << num2 << endl; // print double
cout << "character: " << ch << endl; // print char
return 0;
}