Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We were asked to write a simple program in C language to solve the equation, ax+

ID: 2993495 • Letter: W

Question

We were asked to write a simple program in C language to solve the equation, ax+b=0, for x. If a is 0, print a warning message and exit. This is what I have so far, but it's not compiling. Please correct my program and make comments as to what is wrong.

#include <stdio.h>

int main()

{

float a, b, x;

printf("Enter a and b separated by a comma="); scanf("%f, %f", &a, &b);

if (a==0){ printf("You entered an invalid number. "); return 0;}

else x=-b/a;

printf("x= %f -b/a ", a, b,);

return 0;

}

Explanation / Answer

#include <stdio.h>


int main()


{


float a, b, x;



printf("Enter a and b separated by a comma ");


scanf("%f, %f", &a, &b);


if (a==0){ printf("You entered an invalid number. "); return 0;}


else x=-b/a;


printf("x= %f",x);


return 0;


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote