Cplab 2 Up
Cplab 2 Up
Objective(s):
1. To be able to use standard data types in C++
2. To be able to Declare and Initialize Variables
3. To be able to apply Declare and Define Constants
4. To be able to use of Arithmetic Operators
Exercises
Write a program that takes 3 values from user. Two values of integer and one value of float data
type. Print each result on one line.
Write simple calculator program takes an arithmetic operator +, -, *, / and two operands from the
user. Then, it performs the calculation on the two operands depending upon the operator entered
by the user.
Expected Output:
s CSL-113: Computer Programming Lab
Exercise 3 (Percentage)
Write a C++ program that prompt input roll number, student name and marks of three subjects
1. Computer Programming = CP
2. Introduction to communication Technologies = ICT
3. Data Science = DS
Calculate total marks, percentage of student.
Marks percentage = marks obtained / total * 100
Write a program to solve the following equation. Take value of a and b from user.
X = (a + b)²
Write a program that plays a word game with the user. The program should ask the user to enter
the following also display user age in days from current date.
User’s name
Year of birth (eg. 1990)
Name of university
A favorite hobby
A pet’s name
Hypotenuse refers to the right angle in a triangle (as shown in the side opposite right-angled the
diagram below).
Hypotenuse can be calculated using the following formula:
Area of this right-angled triangle can also be calculated using the following formula: a = ½ * x *
y
Note that:
h=Hypotenuse
x= adjacent
y= opposite
Write a C++ program that prompt user to enter value of X and Y. You have to calculate the value
of Hypotenuse (h) and Area(a).