C Programming : Write a program to find the roots of a quadratic equation.

Posted on:
tags: ,

Q4: Write a program to find the roots of a quadratic equation.



#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,p;
double x;
clrscr();
                printf("\n\t\tEnter value of a:\n\t\tEnter value of b:\n\t\tEnter the value of c:");
                scanf("%d,%d,%d",&a,&b,&c);

                                x=-b+sqrt(((b*b)-4*a*c)/2);
                                x=-b-sqrt(((b*b)-4*a*c)/2);

                                p=(b*b)-4*a*c;

                                switch(p)
                                {
                                                case :
                                                                printf("\n\t\t The Roots Are Real And Unequal...");
                                                                break;
                                                case 'p==0':
                                                                printf("\n\t\t The Roots Are Real And Equal...");
                                                                break;
                                                case 'p<0':
                                                                printf("\n\t\t The Roots Are imaginary...");
                                                                break;
                                }

                getch();
}

No comments:

Post a Comment

< >