Write an algorithm to find (a+b)²
Answers
Basically
(a+b)^2 = a^2 + b^2 + 2ab
Answer:
The algorithm to find (a+b)² was given below
Explanation:
Algorithm:
- The logical list of procedures or steps used for solving the given problem is known as Algorithm.
- The process is usually carried out by the computer.
The properties that the algorithm should have is:
- The algorithm should be simple and easy to read.
- It should be clear with no ambiguity
- It should have unique solution for the problem
- To arrive the solution it should have finite number of steps.
While solving the problems the unexpected situation may arise the algorithm should have the capability to solve the problem.
Before writing the program to solve the problem, the algorithm or the flow chart will be drawn to predict the outcome of the problem.
Given:
Algorithm to find (a+b)²
Solution:
Algorithm: To find the sum of the squares of the given number.
Step 1 : Read A, B
Step 2 : Let sum = A + B
Step 3 : Let the sum of the squares of the product = (A + B)²
Step 4 : Print The sum of the squares of the product
Step 5 : Stop
Note: First the sum of the two numbers will be done then the square will be taken for the answer of the sum value. If the answer was negative it will printed as positive value due to squaring the number.
#SPJ2