Search:

Submit Article

# Program to solve the equation

Posted By: Hilma Miller     Category: C Programming     Views: 6117

## Code for Program to solve the equation in C Programming

#include<stdio.h>
#include<math.h>

void main()
{
float a,b,c,delta,x,y,root1,root2;

printf("enter the value of first variable");
if(scanf("%f",&a)==1)
{
printf("enter the value of second  variable");
if(scanf("%f",&b)==1)
{
printf("enter the value of third variable");
if(scanf("%f",&c)==1)
{
delta=sqrt(pow(b,2)-(4*a*c));
if(delta>0)
{
root1=(-b+delta)/(2*a);
root2=(-b-delta)/(2*a);
printf("\n\n root1=%5.2f",root1);
printf("\n\n root2=%5.2f",root2);
}
else
{
printf("roots are imaginary");
}
}
else
{
printf("error,enter correct value");
}
}
else
{
printf("error,enter the correct value");
}
}
else
{
printf("error,enter coreect value");
}

}

===============================OUTPUT==============================

enter the value of first variable :1.5
enter the value of second  variable :3.5
enter the value of third variable :-15

root1= 2.20

root2=-4.54
Share:

Didn't find what you were looking for? Find more on Program to solve the equation Or get search suggestion and latest updates.

 Hilma Miller author of Program to solve the equation is from Frankfurt, Germany. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!