/* write a program to find the roots of the quadratic equation where the value of a, b, and c are entered by user*/
# include<stdio.h>
#include<conio.h>
void main()
{ float a,b,c,term,r1,r2;
printf("\n Enter the value for a,b and c =\n");
scanf("%f%f%f ",&a,&b,&c);
term= b*b-4*a*c;
if(term<0)
printf( "\n Imaginary Roots ");
elseif(term==0)
{ printf("\n Roots are real and equal");
r1= -b/(2*a);
r2=r1;
printf("\n r1=%f",r1);
printf("\n r2=%f",r2);
}
elseif(term>0)
{ printf("\n Roots are real and and distinct")
r1=(-b+sqrt(term))/(2*a);
r2=(-b-sqrt(term))/(2*a)
printf("\n r1=%f",r1);
printf("\n r2=%f",r2);
}
getch();
}
/*- output :--
Enter the value for a,b and c =1
2
3
Imaginary Roots
*/
👆😊💬ðŸ’
No comments:
Post a Comment
This Blog helps you to learn basics to high level programming coding and practicals.
conceptual understanding