You are on page 1of 4

LAB-1 SOLUTION:

Algorithm to display the product of two numbers:


Input: Two numbers, num1 and num2
Output: The product of num1 and num2
Step 1: Read num1
Step 2: Read num2
Step 3: Calculate product = num1 * num2
Step 4: Display product
Step 5: End
Algorithm to display the remainder when one number is divided
by the other using the Mod (%) operator:
Input: Two numbers, dividend and divisor
Output: The remainder when dividend is divided by divisor
Step 1: Read dividend
Step 2: Read divisor
Step 3: Calculate remainder = dividend % divisor
Step 4: Display remainder
Step 5: End
Algorithm to display the area of a parallelogram:
Input: Base and height of the parallelogram
Output: Area of the parallelogram
Step 1: Read base
Step 2: Read height
Step 3: Calculate area = base * height
Step 4: Display area
Step 5: End
Algorithm to display the area and perimeter of a circular plot:
Input: Radius of the circle (r)
Output: Area and perimeter of the circle
Step 1: Read radius (r)
Step 2: Calculate area = 3.14 * r * r
Step 3: Calculate perimeter = 2 * 3.14 * r
Step 4: Display area and perimeter
Step 5: End
Algorithm to display the area of a triangle:
Input: Base and height of the triangle
Output: Area of the triangle
Step 1: Read base
Step 2: Read height
Step 3: Calculate area = (base * height) / 2
Step 4: Display area
Step 5: End
Algorithm to display the area and perimeter of a square:
Input: Length of the square's side
Output: Area and perimeter of the square
Step 1: Read length
Step 2: Calculate area = length * length
Step 3: Calculate perimeter = 4 * length
Step 4: Display area and perimeter
Step 5: End
Algorithm to display the volume and surface area of a sphere:
Input: Radius of the sphere (r)
Output: Surface area and volume of the sphere
Step 1: Read radius (r)
Step 2: Calculate surface area = 4 * 3.14 * r * r
Step 3: Calculate volume = (4/3) * 3.14 * r * r * r
Step 4: Display surface area and volume
Step 5: End
Algorithm to convert meters to kilometers:
Input: Length in meters (m)
Output: Length in kilometers (km)
Step 1: Read length in meters (m)
Step 2: Calculate length in kilometers (km) = m / 1000
Step 3: Display length in kilometers (km)
Step 4: End
Algorithm to determine the cost of bananas:
Input: Rate for a dozen bananas and quantity of bananas in dozen
Output: Total cost of bananas
Step 1: Read rate for a dozen bananas
Step 2: Read quantity of bananas in dozen
Step 3: Calculate total cost = (rate for a dozen bananas * quantity of dozens)
Step 4: Display total cost
Step 5: End
Algorithm to find simple interest:
Input: Principal amount, interest rate per year, and total number of years
Output: Simple Interest (SI)
Step 1: Read principal amount (P)
Step 2: Read interest rate per year (R)
Step 3: Read total number of years (T)
Step 4: Calculate Simple Interest (SI) = (P * R * T) / 100
Step 5: Display Simple Interest (SI)
Step 6: End

You might also like