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

Objective : This assignment will allow you to practice with for input/output and

ID: 3695537 • Letter: O

Question

Objective:

This assignment will allow you to practice with for input/output and solve a problem using primitive variables.

Overview:

You are going to write a program to calculate roots of quadratic equations in the form:

For simplification, A, B, and C can be just integers.

Formula to solve for a quadratic equation is:

Specification:

Your program will clearly ask users for their names, and politely acknowledge it.

It will then ask for the coefficients A, B, and C.

It will calculate and then display the two roots.

You may use Ax^2 + Bx +C to describe the quadratic, because superscript is very challenging to display.

You will need to use Math.sqrt().

Your program may ignore these possible error conditions:

Un-parseable use input for a number

Complex roots

You are free to allow your program to crash under these conditions.

Explanation / Answer

Here is the code

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int a,b,c;
float r1,r2,up;
printf("Enter value of a : ");
scanf("%d", &a);
printf("Enter value of b : ");
scanf("%d", &b);
printf("Enter value of c : ");
scanf("%d", &c);
up=(b*b)-(4*a*c);
if(up>0)
{
printf(" ROOTS ARE REAL ROOTS ");
r1 = ((-b) + sqrt(up)) /(2*a);
r2 = ((-b) - sqrt(up)) /(2*a);
printf(" ROOTS : %f, %f ", r1, r2);
}
else if(up==0)
{
printf(" ROOTS ARE EQUAL ");
r1 = (-b/(2*a));
printf(" ROOT IS...: %f ", r1);
}
else
printf(" ROOTS ARE IMAGINARY ROOTS ");
getch();
return 0;
}