#include <stdio.h>
void print_quadratic(int a, int b, int c)
{
if(a!=0)
{
printf("%dx^2 ",a);
}
if(b!=0)
{
if(b>0)
{
printf("+ %dx ",b);
}
else
{
printf("- %dx ",-b);
}
}
if(c!=0)
{
if(c>0)
{
printf("+ %d ",c);
}
else
{
printf("- %d ",-c);
}
}
}
int main (void)
{
printf("Enter a:\n");
printf("Enter b:\n");
printf("Enter c:\n");
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
print_quadratic(a,b,c);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter