program to find roots of quadratic equations

C4fun. Bring you the new concept everyday . Now its to change the scinero and move on to the new problem .the concept let us find the roots of the given equation by making a simple program

Are you looking for the new project or are you looking for the new program see for fun brings you the new program that is we have to find the roots of the quadratic equation given now the question arises how to do that the most and the simple things to do first we have to find the degree of the equation given from this we may get to know the type of roots we are going to obtain. Depending upon the roots we have obtained this can be of three types like real equal or imaginary.


Below is the step by step guide to help you find the
Desired output

how to proceed?

First step is described as below

First, the program found out the discriminant by the formula 

( b * b – 4 * a * c) .by which we are came to know that there may exist  3 types of roots. 

They may be complex or distinct or may be equal roots.

 We have to find the roots

The source code has been supplied to you , but before moving on to the programming solution you must try yourself first it will help you to boost your confidence
Here is code by c4fun for the program to calculate the roots. 


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
float d,x1,x2;
clrscr();
printf("\n enter value of a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=((b*b)-(4*a*c));
if(d>=0)
{
printf("\n real roots\n");
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("\nroot 1=%f",x1);
printf("\n root 2=%f",x2);
}
else
{
d=-d;
printf("\n imaginary roots\n");
x1=-b/(2*a);
x2=sqrt(d)/(2*a);
printf("root 1 =%f +i%f",x1,x2);
printf("root 2=%f-i%f",x1,x2);
}
getch();
}

What was the result you have obtained by the program you have made was it good was you able to modify it as you have desired if the answer is yes then you are on the right track you are making a good program then you are on the right track share with your friends how was your experience about making the basic programs and what result you have obtained

Comment comment down your experiences and the result you have obtained.
Share the program among your friends and relatives and help others to know the basic program and the problem they might be facing making logic help them in finding the logic behind the programming as C for fun believes in sharing and caring

The output of test you should comment to see what different result  you are geeting.
If you have any question or query or doubt you can comment below the answer of that would be there in no time do share and comment the experience and answers let's make a play of comments keep learning
Keep coding
Try new things...

1 comment:

thanks for reading and sharing.I hope it would help you!!!!

Powered by Blogger.