program to find the roots of a quadratic equation
Answer Posted / zainab
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int a,b,c;
float d,p,q,r,s;
printf("\n\n Enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d==0)
{
printf("\n The roots are real and equal");
p=(-b)/(2*a);
q=(-b)/(2*a);
printf("\n The roots of the equation are %f,%f",p,q);
}
if(d>0)
{
printf("\n The roots are real and distinct");
p=((-b)+sqrt((b*b)-(4*a*c)))/(2*a);
q=((-b)-sqrt((b*b)-(4*a*c)))/(2*a);
printf("\n The roots of the equation are %f,%f",p,q);
}
if(d<0)
{
printf("\n The roots are imaginary");
r=(-b)/(2*a);
s=(sqrt((4*a*c)-(b*b)))/(2*a);
printf("\n The roots of the equation are
p=%f+%fi,q=%f-%fi",r,s,r,s);
}
getch();
}
Is This Answer Correct ? | 17 Yes | 27 No |
Post New Answer View All Answers
Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange
Develop a routine to reflect an object about an arbitrarily selected plane
how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns
Write a routine to implement the polymarker function
In a gymnastic competition, scoring is based on the average of all scores given by the judges excluding the maximum and minimum scores. Let the user input the number of judges, after that, input the scores from the judges. Output the average score. Note: In case, more than two judges give the same score and it happens that score is the maximum or minimum then just eliminate two scores. For example, if the number of judges is 5 and all of them give 10 points each. Then the maximum and minimum score is 10. So the computation would be 10+10+10, this time. The output should be 10 because 30/3 is 10.
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
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
What is data _null_? ,Explain with code when u need to use it in data step programming ?
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 ?
#include
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']
How to palindrom string in c language?
write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??
Cluster head selection in Wireless Sensor Network using C programming language.
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.