program to find the roots of a quadratic equation

Answer Posted / jijo alexander

#include<stdio.h>
void main()
{
int a,b,c;
float d,r1,r2;

printf("\n\n\t\tSolving the quadratic equation");
printf("\n\t\t********************************");


printf("\n\n\tEnter The Coefficent");
printf("\n\t======================");


/*Out put screen */

printf("\n\tCoefficent Of 'X^2' : ");
scanf(%d",&a);

printf("\n\tCoefficent Of 'X' : ");
scanf("%d",&b);

printf("\n\tConstant Value : ");
scanf("%d",&c);

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

if(d<0)
printf('\n\n\tImaginary Roots ");
else if(d==0)
{
r1=(-b)*(2*a);
printf("\n\tEqual Roots");
}
else
{
printf("\n\tReal roots : ");
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
printf("\t %g , %g",r1,r2);
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3342


Write a program to model an exploding firecracker in the xy plane using a particle system

3866


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4071


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2497


Sir... please give some important coding questions asked by product companies..

2019






Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

3073


why nlogn is the lower limit of any sort algorithm?

2541


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

2887


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2564


how to test pierrot divisor

2457


could you please send the program code for multiplying sparse matrix in c????

3276


How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

2253


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

2351


Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

3244


Cluster head selection in Wireless Sensor Network using C programming language.

3375