Ok the question is this..........

Write a function that will calculate and display the real roots of the quadratic equation

ax2 + bx+c = 0

use the function in the program.

I have coded this

Code:

#include <stdio.h>
#include <math.h>
int main(void)
{
int a, b, c, D;
double root1, root2;
printf("Enter a,b,c for the quadratic equation\n");
scanf("%d %d %d",&a,&b,&c);
check(a, b, c, D, root1, root2);
}
int check(int a, int b, int c, int D, double root1, double root2)
{
if ((a==0) && (b==0)) {
printf("This equation has no solution");
}
else if (a==0){
root1=(-c/a);
printf("This equation has only one root %lf",root1);
}
else {
D = (b*b - 4*a*c);
if (D>0){
root1 = (-b + sqrt(D))/(2*a);
root2 = (-b - sqrt(D))/(2*a);
printf("The real roots are %lf & %lf",root1,root2);
}
else if (D<0){
printf("There are no real roots");
}
else {
root1 = root2 = (-b/2*a*c);
printf("The repeated roots are %lf",root1);
}
}
}

This is working fine, but i want to know that is it efficient & correct answer to the question??

if not how to make it more efficient.

Also how can i make it multi function code.......i mean check will be for checking of a, b, c & then it will return to main function & new calculate function will be called where all calculations will be made