Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lab Manual (Arithmetic Operators in calculation)

Introduction to Computing

Program#1:
Write a program that takes input of two numbers then calculate their sum and output the result.
Output:
Enter first number: 23
Enter second number: 16
Sum of 23 and 16 is 39

Program#2:
Write a program that takes input of two numbers then calculate their sum, difference, product
and quotient then output the result.
Output:
Enter first number: 13
Enter second Number: 7
Sum of 13 and 7 is: 20
Difference of 13 and 7 is: 6
Product of 13 and 7 is: 91
Dividing 13 by 7 results: 1.85714

Program#3:
Write a program that takes input for the radius of a circle then calculate its area, circumference
and diameter, then output the three results.
(Area= π r2 circumference=2πr diameter=2r)
Output:
Enter radius of circle: 13
Area of circle is: 530.92871
Diameter of circle is: 26
Circumference of circle is: 81.68134

Program#4:
Write a program that takes input of a number then calculate its square and inverse, then output
the result.
( square = x*x inverse = 1/x )
Output:
Enter a number: 18
Square of 18 is: 324
Inverse of 18 is: 0.05555
Program#5:
Write a program that takes input of three numbers, then calculate their sum and average, then
output the result.
Output:
Enter three numbers: 12
34
65
Sum of 12, 34 and 65 is 111
Average of 12, 34 and 65 is 37

Program#6:
Write a program that takes input of two sides of rectangle then calculate and print area of
rectangle.
(Area=length*width perimeter=2*( length + width ) )

Output:
Enter length of rectangle: 15.6
Enter width of rectangle: 21
Area of rectangle is: 327.6
Perimeter of rectangle is: 18.3

Program#7:
Write a program that takes input of three sides of a triangle then calculate the area of triangle.
(Area = (B*H)/2 perimeter = B+H+P)

Output:
Enter base value of triangle: 6
Enter perpendicular value of triangle: 9
Enter hypotenuse value of triangle: 8
Area of triangle is: 7
Perimeter of triangle is: 23

You might also like