0% found this document useful (0 votes)
3 views3 pages

Write Anglorithm That Will Do Following - Ask T...

The document introduces the concept of an 'anglorithm', a playful term for algorithms written in clear, English-like pseudocode. It provides three algorithms: one for calculating the Highest Common Factor (HCF), another for the Least Common Multiple (LCM), and a third for finding the roots of a quadratic equation. Each algorithm is detailed with step-by-step instructions for implementation.

Uploaded by

dragonlinux42
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)
3 views3 pages

Write Anglorithm That Will Do Following - Ask T...

The document introduces the concept of an 'anglorithm', a playful term for algorithms written in clear, English-like pseudocode. It provides three algorithms: one for calculating the Highest Common Factor (HCF), another for the Least Common Multiple (LCM), and a third for finding the roots of a quadratic equation. Each algorithm is detailed with step-by-step instructions for implementation.

Uploaded by

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

An "anglorithm" is not a standard term in computer science.

It seems like a playful or


portmanteau word combining "Anglo" and "algorithm," possibly implying an algorithm
written in a clear, English-like, step-by-step manner.

Assuming you're asking for algorithms described in a clear, structured English format
(pseudocode), here's how you can approach each of the tasks you described:

Algorithm 1: Find the HCF (Highest Common Factor) of two numbers


Anglorithm: CalculateHCF
1.​ START
2.​ DECLARE integer variables num1, num2, remainder, hcf
3.​ DISPLAY "Enter the first number:"
4.​ INPUT num1
5.​ DISPLAY "Enter the second number:"
6.​ INPUT num2
7.​ IF num1 is 0 THEN
○​ hcf = num2
8.​ ELSE IF num2 is 0 THEN
○​ hcf = num1
9.​ ELSE (Use Euclidean Algorithm)
○​ WHILE num2 is NOT 0 DO
■​ remainder = num1 MOD num2
■​ num1 = num2
■​ num2 = remainder
○​ hcf = num1
10.​DISPLAY "The HCF is: ", hcf
11.​ END

Algorithm 2: Find the LCM (Least Common Multiple) of two numbers


Anglorithm: CalculateLCM
1.​ START
2.​ DECLARE integer variables num1, num2, lcm, product
3.​ DECLARE function CalculateHCF(a, b) (referencing the HCF algorithm above)
4.​ DISPLAY "Enter the first number:"
5.​ INPUT num1
6.​ DISPLAY "Enter the second number:"
7.​ INPUT num2
8.​ IF num1 is 0 OR num2 is 0 THEN
○​ lcm = 0
9.​ ELSE
○​ product = num1 * num2
○​ hcf_value = CalculateHCF(num1, num2)
○​ lcm = product / hcf_value
10.​DISPLAY "The LCM is: ", lcm
11.​ END

Algorithm 3: Find the roots of a quadratic equation


A quadratic equation is of the form ax2+bx+c=0, where a, b, and c are coefficients
and a=0.

Anglorithm: FindQuadraticRoots
1.​ START
2.​ DECLARE real variables a, b, c, discriminant, root1, root2, realPart, imaginaryPart
3.​ DISPLAY "Enter the coefficient 'a':"
4.​ INPUT a
5.​ DISPLAY "Enter the coefficient 'b':"
6.​ INPUT b
7.​ DISPLAY "Enter the coefficient 'c':"
8.​ INPUT c
9.​ IF a is 0 THEN
○​ DISPLAY "Error: 'a' cannot be zero for a quadratic equation. This is a linear
equation."
○​ IF b is NOT 0 THEN
■​ root1 = -c / b
■​ DISPLAY "The equation is linear. The root is: ", root1
○​ ELSE
■​ DISPLAY "Invalid equation. Both 'a' and 'b' are zero."
10.​ELSE
○​ discriminant = b*b - 4*a*c
○​ IF discriminant > 0 THEN
■​ root1 = (-b + SQRT(discriminant)) / (2*a)
■​ root2 = (-b - SQRT(discriminant)) / (2*a)
■​ DISPLAY "The roots are real and distinct:"
■​ DISPLAY "Root 1 = ", root1
■​ DISPLAY "Root 2 = ", root2
○​ ELSE IF discriminant = 0 THEN
■​ root1 = -b / (2*a)
■​ DISPLAY "The roots are real and equal:"
■​ DISPLAY "Root 1 = Root 2 = ", root1
○​ ELSE (discriminant < 0)
■​ realPart = -b / (2*a)
■​ imaginaryPart = SQRT(ABS(discriminant)) / (2*a)
■​ DISPLAY "The roots are complex and conjugate:"
■​ DISPLAY "Root 1 = ", realPart, " + ", imaginaryPart, "i"
■​ DISPLAY "Root 2 = ", realPart, " - ", imaginaryPart, "i"
11.​ END

You might also like