0% found this document useful (0 votes)
11 views

Computer Programming CP - Bahria

The document outlines 6 tasks for a computer programming lab. The tasks include getting user input of different data types, performing arithmetic operations, calculating percentage, solving equations, playing a word game with user input, and calculating the hypotenuse and area of a right triangle given side lengths.

Uploaded by

andreytagno
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 (0 votes)
11 views

Computer Programming CP - Bahria

The document outlines 6 tasks for a computer programming lab. The tasks include getting user input of different data types, performing arithmetic operations, calculating percentage, solving equations, playing a word game with user input, and calculating the hypotenuse and area of a right triangle given side lengths.

Uploaded by

andreytagno
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/ 3

CSL-113: Computer Programming Lab

Semester : Fall-2022
Lab Engineer : Fatima Bashir

Lab 02: Variables and Data Types

TASKS

Task 1: User Input

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.

Task 2: Arithmetic Operations

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.
CSL-113: Computer Programming Lab
Semester : Fall-2022
Lab Engineer : Fatima Bashir

Task 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

Task 4 : Calculating Value of X

Write a program to solve the following equation. Take value of a and b from user.

X = (a + b)2

Task 5 : Word Game

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

Write a program that will produce an outcome as below:


CSL-113: Computer Programming Lab
Semester : Fall-2022
Lab Engineer : Fatima Bashir

Task 6

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).

You might also like