Untitled
unknown
c_cpp
9 months ago
779 B
4
Indexable
#include<iostream>
#include<cmath>
using namespace std;
void main(){
double a , b , c;
cout << "Enter a = ";
cin >> a;
cout<<"Enter b = ";
cin>>b;
cout<<"Enter c = ";
cin >> c;
if (a == 0)
{
if (b == 0)
{
cout<<"a ya b hadeaghal yekishon gheir sefr bashand"<< endl;
} else
{
double x = -c/b;
cout<<"x = "<<x<<endl;
}
} else {
double delta=b*b-4*a*c;
if (delta<0){
cout<<" moyadele ghabele hal nist "<< endl;
} else {
double x1 = (-b + sqrt(delta)) / 2 * a;
double x2 = (-b - sqrt(delta)) / 2 * a;
cout<<"x = "<<x1<<" va " <<x2<<endl;
}
}
}
Editor is loading...
Leave a Comment