السلام عليكم ورحمة الله وبركاته
حبآيبي
عندي هالسؤال :
Write a program that solve an algebraic equation of the second degree ax2+ bx+c=0.
وطلب مني آستخدام math library
وهذي محاولتي في الحل
#include <math.h>
using namespace std;
int delta(int a,int b, int c);
{
int r;
r=((b*b)-(4*a*c)); // Calculate delta
return r;}
int main(){
int a,b,c;
float x1,x2;
cout << "Quadratic eq solver" << endl;
do{
cout << "Input a: ";
cin >> a;
if (a==0)
cout << "Input b: ";
cin >> b;
cout << "Input c: ";
cin >> c;
if (delta(a,b,c)>=0){
x1=(-b+sqrt(delta(a,b,c)))/2*a;
x2=(-b-sqrt(delta(a,b,c)))/2*a;
if (x1!=x2) //If delta > 0 then show the value of X
cout << x1 << ", " << x2 << endl; //If x1 is ot equal to x2 show the two values
else // Else the show only the value of x1
cout << x1 << endl;}
else
cout << "Negative delta!" << endl;
cout << "------------------------------\n\n";}
while (a!=0);
return 0;
}
#include <iostream>
لكن يعطيني خطأ =(
تعبت من هالسؤال
ما ادري وين الخطأ بالكود !!
آتمنـى مساعدتكـم ..~