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

LAB - 3.1 Bscs Fall 2020: Introduction To Computing

This document outlines 3 tasks for a computing lab assignment. Task 1 involves writing programs to: a) print 3 numbers in reverse order, b) calculate total minutes from hours and minutes input, and c) display hours and minutes from minutes input. Task 2 involves writing a program to calculate mathematical operations (addition, subtraction, multiplication, division) on two variables and output the results. Task 3 involves writing a program to calculate the perimeter and area of a rectangle given length and width, first with hardcoded values then taking length and width as user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

LAB - 3.1 Bscs Fall 2020: Introduction To Computing

This document outlines 3 tasks for a computing lab assignment. Task 1 involves writing programs to: a) print 3 numbers in reverse order, b) calculate total minutes from hours and minutes input, and c) display hours and minutes from minutes input. Task 2 involves writing a program to calculate mathematical operations (addition, subtraction, multiplication, division) on two variables and output the results. Task 3 involves writing a program to calculate the perimeter and area of a rectangle given length and width, first with hardcoded values then taking length and width as user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

INTRODUCTION TO COMPUTING

LAB – 3.1
BSCS FALL 2020

Faculty of Information Technology


University of Central Punjab
TASK – 01
a) Write a program that takes 3 numbers from user and print them in reverse order

Sample Input:
12, 20, 5
Expected Output:
The reverse of 12 , 20 and 5 is 5, 20 and 12

b) Get hours and minutes as input from user, and calculates the total number of
minutes.
Expected Output:
Input hours: 5
Input minutes: 37
Total: 337 minutes.

c) Get minutes as input from user, and display the total number of hours and
minutes.
Expected Output :
Input minutes: 546
9 Hours, 6 Minutes

TASK – 02
You have to write a C++ program that will have two variables [x and y] both integer, you have
to assign some value to the both variables, and then you have to show [Let x = 25, y = 13]

Your program should show the following output on the screen

Output on the screen should be


Value of x is 25 and value of y is 13
Sum of x + y is 38
Difference of x – y is 12
Difference of y – x is -12
Multiplication of x * y is 325
Division of x / y is 1
Division of y / x is 0
Now update this program, add some more variables, and store all the results in the variables,
all variables should be integer [Sum, Sub, Sub1, Mul, Div, Div1]

Sum = x + y
Sub = x – y
Sub1 = y – x
Mul = x * y
Div = x / y
Div1 = y / x

Output on the screen should remain the same as before now think where you have to
use variables to show the results.

Now again update the program and get value of x and y as an input from the user

Please enter value of x: 20


Please enter value of y: 32

Value of x is 20 and value of y is 32


Sum of x + y is 52
Difference of x – y is -12
Difference of y – x is 12
Multiplication of x * y is 640
Division of x / y is 0
Division of y / x is 1

Repeat the other case for the output; use the other variables [Sum, Sub, Sub1, Mul, Div,
Div1] for storing result
TASK – 03
You have to write a C++ program that will find the perimeter and area of a rectangle. To find the
perimeter and area of a rectangle, you need to know the rectangle’s length and width.

You have to define two variables [length and width] and assign values to both. You
have to calculate

1. Perimeter = 2 * (length + width)


2. Area = length * width

Let length = 15, width = 21

Output should be

Length of the Rectangle is: 15


Width of the Rectangle is: 21
Perimeter of the Rectangle is: 72
Area of the Rectangle is: 315

Change this program and get both length and width values from the user as an input.

Output should be

Please enter length of the rectangle: 22


Please enter width of the rectangle: 15
……………………………………………..
Length of the Rectangle is: 22
Width of the Rectangle is: 15
Perimeter of the Rectangle is: 74
Area of the Rectangle is: 330

You might also like