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

3, Solve forthe roots: x2 + 4-0 A math teacher needs to quiz students about solv

ID: 3747900 • Letter: 3

Question

3, Solve forthe roots: x2 + 4-0 A math teacher needs to quiz students about solving the about cheating, so she wants to give each student a one with complex roots. In each case, the roots will have September 16, 2018 quiz to so Name: roots, one with real roots, and L. Solve for the roots +4r+30 the Repeated roots: In the range -5 to 5, but cannot be 0. Real roots: Both in the range -5 to 5; the first root cannot be 0, the second cannot be the same as the first Complex roots: Real and imaginary parts in the range:-5 to 5; the imaginary part cannot be 0 Discriminant 42-4-1-3:16-11-4 (a) The quiz questions (for the student) b) The answer key (for the teacher) d> 0: Real Roots September 15, 2018 1. Solve for the roots: x24x+3 0 2-1.5-1=-25 2. Solve for the roots: x2+7x-2-0

Explanation / Answer

#include <stdio.h>

#include <math.h>

void print_roots(int a, int b, int c){

double determinant, root1,root2, realPart, imaginaryPart;

determinant = b*b-4*a*c;

// condition for real and different roots

if (determinant > 0)

{

// sqrt() function returns square root

root1 = (-b+sqrt(determinant))/(2*a);

root2 = (-b-sqrt(determinant))/(2*a);

printf(" root1 = %.2lf and root2 = %.2lf ",root1 , root2);

}

//condition for real and equal roots

else if (determinant == 0)

{

root1 = root2 = -b/(2*a);

printf(" root1 = root2 = %.2lf; ", root1);

}

// if roots are not real

else

{

realPart = -b/(2*a);

imaginaryPart = sqrt(-determinant)/(2*a);

printf(" root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi ", realPart, imaginaryPart, realPart, imaginaryPart);

}

}

int main(void) {

// your code goes here

//for repeated roots-

/*

(x-a)(x-a)=0

x^2-a^2 x+a^2=0

-5<=a<=5

*/

printf(" For repeated roots -> ");

for(int a=-5;a<=5;a++){

printf(" x^2 - %d x + %d ", 2*a, a*a);

print_roots(1, 2*a, a*a);

}

//for real roots

//D>0

/*

(x-a)(x-b)=0

x-(a+b)x+ab=0

D=(a+b)^2-4ab

*/

printf(" For Real roots -> ");

for(int a=-5;a<=5;a++){

if(a==0)

continue;

for(int b=-5;b<=5;b++){

if(a==b){

break;

}

if(pow(a+b, 2)-4*a*b > 0){

printf(" x^2 - %d x + %d ", a+b, a*b);

print_roots(1, -1*(a+b), a*b);

}

}

}

//for imaginary roots

printf("For Imaginary roots roots -> ");

for(int b=-10; b<=10; b++){

if(b==0)

continue;

for(int a=-10; a<=10;a++){

if(a==0){

continue;

}

for(int c=-10; c<=10; c++){

if(c==0)

continue;

if((pow(b, 2)- 4*a*c)<0){

int x=-1*(pow(b, 2)-4*a*c);

if(-5<=sqrt(x)/2<=5){

printf(" %d x^2 + %d x + %d ", a, b, c);

print_roots(a, b, c);

}

}

}

}

}

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