0% found this document useful (0 votes)
16 views

Algo of Rootz

This document discusses algorithms for solving quadratic equations. It provides: 1) A formula for calculating the roots of a quadratic equation using the values of a, b, and c. 2) Instructions for determining the number and type of roots (real or imaginary) based on the discriminant. 3) A C program example to find the roots of a quadratic equation given values for a, b, and c.

Uploaded by

Rahil Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Algo of Rootz

This document discusses algorithms for solving quadratic equations. It provides: 1) A formula for calculating the roots of a quadratic equation using the values of a, b, and c. 2) Instructions for determining the number and type of roots (real or imaginary) based on the discriminant. 3) A C program example to find the roots of a quadratic equation given values for a, b, and c.

Uploaded by

Rahil Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

THE ALGORITHM OF QUADRATIC EQUATION

The roots are given by the following formula

1. 2. 3. 4. 5.

Read values of a, b and c, if a is zero then stop as we do not have a quadratic, calculate value of discriminant D=b*b-4*a*c if D is zero then there is one root: x=-b/2*a , if D is > 0 then there are two real roots: -b+sqrt(D)/2*a and bsqrt(D)/2*a. 6. if D is < 0 there will be imaginary roots. 7. Print solution.

C Program to find the roots of quadratic equation


#include<stdio.h> #include<conio.h> void main() { float dis, x1, x2, a, b, c; clrscr(); printf("\n Enter the value of a b c"); scanf("\n%f%f%f",&a,&b,&c); dis=b*b-4*a*c; if (dis>0) { x1=-b/2*a+sqrt(dis)/2*a; x2=-b/2*a-sqrt(dis)/2*a; printf("\none root is=%f",x1); printf("\nsecond root is=%f",x2); }8 else if (dis==0) { x1=-b/2*a; x1=x2; printf("\nRoots are equal%f",x1); } else

{ printf("\n roots are imaginry"); } getch(); }

OUTPUT Enter the value of a b c 1 -5 6 one root is=3.000000 second root is=2.000000

A program to find out the largest number among 10 nos using array.
#include<stdio.h> #include<conio.h> void main() { int a[10],i,big; clrscr(); printf("\n Enter the 10 Nos."); for (i=0; i<10; i++) { scanf("\n%d",&a[i]); } big=a[0]; for (i=1; i<10; i++) { if (big<a[i]) big=a[i]; } printf("\nThe Largest No is %d",big); getch(); }

OUTPUT Enter the 10 Nos. 10 15 9 16 15 8 6 9 7 9 The Largest No is 16

You might also like