You cannot add semi colon after if, else if and else statements.
This is a little more complex version of the same code, it takes into account when a and/or b are 0 and the formula changes (the equation becomes linear)
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c;
float r1,r2,r3,r11,r12,r21,r22,D;
printf("Enter values of a,b,c where equation is ax^2+bx+c:\n");
scanf(" %f %f %f",&a,&b,&c);
if(a==0 && b==0)
{
printf("Invalid Input, a and b cannot be %f and %f\n",a,b);
}
else if(a==0 && b!=0)
{
printf("Linear Equation\n");
r3=(-c/b);
printf("The roots of %.1fx^2 + %.1fx + %.1f is %.3f\n",a,b,c,r3);
}
else if(a!=0 && b!=0)
{
D=((b*b)-(4*a*c));
if(D>0)
{
r1=((-b+sqrt(D))/2*a);
r2=((-b-sqrt(D))/2*a);
printf("The roots of %.1fx^2 + %.1fx + %.1f are %.3f and %.3f\n",a,b,c,r1,r2);
}
else if(D<0)
{
r11=(-b)/(2*a);
r12=sqrt(-D)/(2*a);
r21=(-b)/(2*a);
r22=sqrt(-D)/(2*a);
printf("The roots of %.1fx^2 + %.1fx + %.1f are %.3f + %.3fi and %.3f - %.3fi",a,b,c,r11,r12,r21,r22);
}
}
}