write a program to find the roots of the quadratic equation where the value of a, b, and c are entered by user

/* 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

c program, Advance coding, c++ program, simple program, Advance language

online quiz Application project page MCA final year project

  Here we making a quiz application ppt presentation for college project so that our project idea will like to our professor and teacher  fi...