Question

im trying to make a c program that executes the quadratic formula but im having troubles...

im trying to make a c program that executes the quadratic formula but im having troubles finishing it.

#include<math.h>
#include<stdio.h>
int main()
{
double a,b,c,total_1,total_2,total_3,total_4,total_5;

printf("Enter 'a' value> ");
scanf("%lf",&a);

printf("Enter 'b' value> ");
scanf("%lf",&b);

printf("Enter 'c' value> ");
scanf("%lf",&c);

total_1=(-b);
total_2=(b*b)-(4*a*c);
total_3=(2*a);
if (total_2<0)
{
printf("Does not exist\n");
}
else (total_4=(total_1 + (sqrt(total_2))/total_3), total_5=(total_1 - (sqrt(total_2))/total_3)
{
printf("The two roots of the equation are %lf,%lf",&total_4,&total_5);  
}
}

Homework Answers

Answer #1
#include<math.h>
#include<stdio.h>
int main()
{
double a,b,c,total_1,total_2,total_3,total_4,total_5;

printf("Enter 'a' value> ");
scanf("%lf",&a);

printf("Enter 'b' value> ");
scanf("%lf",&b);

printf("Enter 'c' value> ");
scanf("%lf",&c);

total_1=(-b);
total_2=(b*b)-(4*a*c);
total_3=(2*a);
if (total_2<0)
{
printf("Does not exist\n");
}
else 
{
total_4=((total_1 + sqrt(total_2))/total_3);
total_5=((total_1 - sqrt(total_2))/total_3);
printf("The two roots of the equation are %lf,%lf",total_4,total_5);  
}
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C -Language Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ)....
C -Language Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement. Hint: Call FindMax() twice in an expression. #include <stdio.h> double FindMax(double num1, double num2) {    double maxVal;    // Note: if-else statements need not be understood to complete this activity    if (num1 > num2) { // if num1 is greater than num2,       maxVal = num1; // then num1 is the maxVal.    }    else {             //...
NO POINTERS TO BE USED. This is C programming. I am trying to make a function...
NO POINTERS TO BE USED. This is C programming. I am trying to make a function to calculate standard deviation from a hard coded array. Why is my function not returning my stddev value back to main? I keep getting an error saying that stddev is undeclared. #include <stdio.h> #include <math.h> float calcstddev(float examgrades[], int size) {    float sum =0.0;    float mean;    int temp;    float variance;    float stddev;    float difference;    for (temp=0;temp<size;++temp)   ...
Question Rewrite the following C program using switch-case statement. and give me an output please use...
Question Rewrite the following C program using switch-case statement. and give me an output please use printf and scanf #include<stdio.h> int main(void) {      int semester;           printf("What is your Studying Level (1-8)?> ");      scanf("%d" , &semester);      if(semester == 1 || semester == 2)           printf("Your are a freshman!\n ");      else if(semester == 3 || semester == 4)           printf("Your are sophomore!\n ");      else if(semester == 5 || semester == 6)           printf("Your are...
C - Language Write an expression that executes the loop while the user enters a number...
C - Language Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of -1. Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds,...
why's is my csis.txt saving ? #include <stdio.h> FILE*fp; void calculateBMI(void); int main(void) {    fp...
why's is my csis.txt saving ? #include <stdio.h> FILE*fp; void calculateBMI(void); int main(void) {    fp = fopen("csis.txt", "w"); for (int i= 0; i<4; ++i){ calculateBMI(); } fclose(fp); return 0; } void calculateBMI(void){ double weight,height,bmi;    printf("Enetr your weight in pounds:\n\n"); fprintf(fp,"Enter your weight in pounds:\n\n"); scanf("%lf",&weight); printf("Enter height in inches:\n\n"); fprintf(fp,"Enter height in inches:\n\n"); scanf("%lf",&height); bmi=(703*weight)/(height*height);    if (bmi<18.5){ printf("You have a BMI of %.lf, and your weight status is underweight\n",bmi);    fprintf(fp,"You have a BMI of %.lf, and...
Can you translate this C code into MIPS assembly with comment? #include <stdio.h> #include <math.h> #include...
Can you translate this C code into MIPS assembly with comment? #include <stdio.h> #include <math.h> #include <stdlib.h> double fact (double); void main () { int angle_in_D; double term, angle_in_R; float sine = 0; unsigned int i = 1; double sign = 1; int n = 1000; printf ("Please enter an angle (Unit: Degree): "); scanf ("%d", &angle_in_D); angle_in_R = angle_in_D * M_PI / 180.0; do { term = pow(-1,(i-1)) * pow (angle_in_R, (2*i - 1)) / fact (2*i - 1);...
I am trying to write a program that reads a string (in my case a domain...
I am trying to write a program that reads a string (in my case a domain name). What I am struggling with is how to traverse through the array and see if there are any invalid characters in the string such as a semi colon or a space. Here is what I have as of now. #include <stdio.h> int main() {    char min[1];    char max[253];    char domain[253]; printf("Enter a domain: "); scanf("%s", domain);    return 0; }
q7.3 Fix the errors in the code (in C) //This program uses a function called CharacterScan...
q7.3 Fix the errors in the code (in C) //This program uses a function called CharacterScan to read a char from the user //The function must take an int pointer as a parameter //The program should print the char and ascii code for each character the user enters //The program should only exit whe nthe user enters escape #include <stdio.h> char CharacterScan(int*); int main(void){ while(1){ int aCode; int* iPtr; char* c = CharacterScan(iPtr); if(aCode) break; else printf("%c is ASCII code...
I am trying to write a program in C language but keep running into errors. Any...
I am trying to write a program in C language but keep running into errors. Any help would be awesome. here is my code I have so far. #include <stdio.h> #include <conio.h> #include <string.h> int main(){    int lenght, i = 0, state = 0;    char line[100];    printf("enter the string for checking of comment line: \n");    gets(line);    while(i < strline(line)){        switch(state){            case 0: if (line[i] == '/'){               ...
All in C language... Write a complete program that declares an integer variable, reads a value...
All in C language... Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces. Besides the numbers, nothing else should be written to standard output except for spaces separating the values. I got this... and it's wrong #include<stdio.h> int main() { int num; scanf("%d", &num); printf("%d %d %d",num,2*num,num*num); return 0; }