Write down the algorithm for the following questions.a) to calculate the root of a quadratic equation.b) to read the roll no, name and marks of three subjects and calculate the total,percentage and division.c) to check whether a triangle can be formed with the given values for the angles.d) to compute the sum of the first “N” natural numbers.e) to display the multiplication table for a given integer.f) to calculate the factorial of a given number.g) to check whether a given number is an Armstrong number or not.h) to determine whether a given number is prime or not.
Question
Write down the algorithm for the following questions.a) to calculate the root of a quadratic equation.b) to read the roll no, name and marks of three subjects and calculate the total,percentage and division.c) to check whether a triangle can be formed with the given values for the angles.d) to compute the sum of the first “N” natural numbers.e) to display the multiplication table for a given integer.f) to calculate the factorial of a given number.g) to check whether a given number is an Armstrong number or not.h) to determine whether a given number is prime or not.
Solution 1
a) Algorithm to calculate the root of a quadratic equation:
- Start
- Declare variables a, b, c, D, x1, x2, realPart, imaginaryPart.
- Read the values of a, b, c.
- Calculate the discriminant D = b^2 - 4ac.
- If D >= 0, calculate x1 = (-b + sqrt(D)) / (2a) and x2 = (-b - sqrt(D)) / (2a).
- If D < 0, calculate realPart = -b / (2a) and imaginaryPart = sqrt(-D) / (2a).
- Display the roots.
- End
b) Algorithm to read the roll no, name and marks of three subjects and calculate the total, percentage and division:
- Start
- Declare variables roll_no, name, marks1, marks2, marks3, total, percentage.
- Read the values of roll_no, name, marks1, marks2, marks3.
- Calculate total = marks1 + marks2 + marks3.
- Calculate percentage = (total / 300) * 100.
- If percentage >= 60, division = 'First'.
- Else if percentage >= 50, division = 'Second'.
- Else if percentage >= 40, division = 'Third'.
- Else division = 'Fail'.
- Display roll_no, name, total, percentage, division.
- End
c) Algorithm to check whether a triangle can be formed with the given values for the angles:
- Start
- Declare variables angle1, angle2, angle3.
- Read the values of angle1, angle2, angle3.
- If angle1 + angle2 + angle3 == 180, display 'Triangle is possible'.
- Else display 'Triangle is not possible'.
- End
d) Algorithm to compute the sum of the first “N” natural numbers:
- Start
- Declare variables N, sum.
- Read the value of N.
- Calculate sum = N * (N + 1) / 2.
- Display sum.
- End
e) Algorithm to display the multiplication table for a given integer:
- Start
- Declare variables N, i.
- Read the value of N.
- For i = 1 to 10, display N * i.
- End
f) Algorithm to calculate the factorial of a given number:
- Start
- Declare variables N, factorial.
- Read the value of N.
- Set factorial = 1.
- For i = 1 to N, calculate factorial = factorial * i.
- Display factorial.
- End
g) Algorithm to check whether a given number is an Armstrong number or not:
- Start
- Declare variables N, temp, remainder, result.
- Read the value of N.
- Set temp = N and result = 0.
- While temp != 0, calculate remainder = temp % 10, result = result + remainder^3, temp = temp / 10.
- If result == N, display 'Armstrong number'.
- Else display 'Not an Armstrong number'.
- End
h) Algorithm to determine whether a given number is prime or not:
- Start
- Declare variables N, i, flag.
- Read the value of N.
- Set flag = 0.
- For i = 2 to sqrt(N), if N % i == 0, set flag = 1 and break.
- If flag == 0, display 'Prime number'.
- Else display 'Not a prime number'.
- End
Solution 2
a) Algorithm to calculate the root of a quadratic equation:
- Start
- Declare variables a, b, c, D, x1, x2, realPart, imaginaryPart.
- Read the values of a, b, c.
- Calculate the discriminant D = b^2 - 4ac.
- If D >= 0, calculate x1 = (-b + sqrt(D)) / (2a) and x2 = (-b - sqrt(D)) / (2a).
- If D < 0, calculate realPart = -b / (2a) and imaginaryPart = sqrt(-D) / (2a).
- Display the roots.
- End
b) Algorithm to read the roll no, name and marks of three subjects and calculate the total, percentage and division:
- Start
- Declare variables roll_no, name, marks1, marks2, marks3, total, percentage.
- Read the values of roll_no, name, marks1, marks2, marks3.
- Calculate total = marks1 + marks2 + marks3.
- Calculate percentage = (total / 300) * 100.
- If percentage >= 60, division = 'First'.
- Else if percentage >= 50, division = 'Second'.
- Else if percentage >= 40, division = 'Third'.
- Else division = 'Fail'.
- Display roll_no, name, total, percentage, division.
- End
c) Algorithm to check whether a triangle can be formed with the given values for the angles:
- Start
- Declare variables angle1, angle2, angle3.
- Read the values of angle1, angle2, angle3.
- If angle1 + angle2 + angle3 == 180, display 'Triangle can be formed'.
- Else display 'Triangle cannot be formed'.
- End
d) Algorithm to compute the sum of the first “N” natural numbers:
- Start
- Declare variables N, sum.
- Read the value of N.
- Calculate sum = N * (N + 1) / 2.
- Display sum.
- End
e) Algorithm to display the multiplication table for a given integer:
- Start
- Declare variables N, i.
- Read the value of N.
- For i = 1 to 10, display N * i.
- End
f) Algorithm to calculate the factorial of a given number:
- Start
- Declare variables N, factorial.
- Read the value of N.
- Set factorial = 1.
- For i = 1 to N, calculate factorial = factorial * i.
- Display factorial.
- End
g) Algorithm to check whether a given number is an Armstrong number or not:
- Start
- Declare variables N, temp, remainder, result.
- Read the value of N.
- Set temp = N and result = 0.
- While temp != 0, calculate remainder = temp % 10, result = result + remainder^3, temp = temp / 10.
- If result == N, display 'N is an Armstrong number'.
- Else display 'N is not an Armstrong number'.
- End
h) Algorithm to determine whether a given number is prime or not:
- Start
- Declare variables N, i, flag.
- Read the value of N.
- If N <= 1, display 'N is not a prime number'.
- Else set flag = 0, for i = 2 to sqrt(N), if N % i == 0, set flag = 1 and break.
- If flag == 0, display 'N is a prime number'.
- Else display 'N is not a prime number'.
- End
Similar Questions
Write algorithm and flowchart for the following.1. Find the largest among three different numbers entered by the user.2. Find all the roots of a quadratic equation ax 2+bx+c=03. Find the Fibonacci series till term ≤ 1000.4. Determine whether a Temperature is below or above the Freezing Point5. Determine whether a student Passed the exam or not6. Find sum of all even numbers upto n7. Find product of numbers upto n8. Interchange the value of two numbers9. Find area and perimeter of square.10. Find sum of digits of an accepted number
Write down the C code for the following questions.a) Write a program in C to check if a given number is even or odd using the function.b) Write a program in C to swap two numbers using a function.c) Write a program in C to find the square of a number using the function.d) Write a program in C to find the factorial of a number using the function.e) Write a program in C to calculate the area of circle using the function.f) Write a C program to compute the sum of the first “N” natural numbers using thefunction.g) Write a program in C to print the Fibonacci series using the function.
Select all of the methods used to solve quadratic equations.factoringcompleting the squareusing the quadratic formulausing the Pythagorean theoremusing the square root property
14) What is the primary goal of mathematical induction?a) To derive the quadratic formulab) To calculate areas under curvesc) To prove statements for all natural numbersd) To solve algebraic equations
During determination of GCD, division by 0 problem occurs in ________________ algorithmQuestion 7Answera.All of the aboveb.Consecutive integer checkingc.Euclidsd.Middle School Procedure
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.