Hi everyone !
i'm a freshmen in c programming, and we got an assignment to create a program that spit out the roots of an quadratic equation!
I've given it a try but it seems to be wrong somehow that's why i need your help! thanks
the formula is x= (-1/2)*p +- sqrt(1/4)*p^2 -q) and its (p,q) is my in-data. if the equation does not have real root printf("itdoes not have real roots");
my code
obs its by calling a function !!
//
// by Haidar Wahid
//
//
#pragma warning (disable:4996)
#include <stdio.h>
#include<stdlib .h>
#include<math.h >
int squareRoot_of(i nt p, int q, double a); // prototype
int main() {
int x, y;
double z;
z = 0.5;
x = 55;
y = 10;
printf("%d\n%d\ n", squareRoot_of(x ,y,z));
system("pause") ;
}
int squareRoot_of(i nt p, int q, double a) // def
{
return ((-a*p) +- sqrt(a*a*p*p - q));
}
i'm a freshmen in c programming, and we got an assignment to create a program that spit out the roots of an quadratic equation!
I've given it a try but it seems to be wrong somehow that's why i need your help! thanks
the formula is x= (-1/2)*p +- sqrt(1/4)*p^2 -q) and its (p,q) is my in-data. if the equation does not have real root printf("itdoes not have real roots");
my code
obs its by calling a function !!
//
// by Haidar Wahid
//
//
#pragma warning (disable:4996)
#include <stdio.h>
#include<stdlib .h>
#include<math.h >
int squareRoot_of(i nt p, int q, double a); // prototype
int main() {
int x, y;
double z;
z = 0.5;
x = 55;
y = 10;
printf("%d\n%d\ n", squareRoot_of(x ,y,z));
system("pause") ;
}
int squareRoot_of(i nt p, int q, double a) // def
{
return ((-a*p) +- sqrt(a*a*p*p - q));
}
Comment