- 1
Pls help how can me let my code repeated as I like in c++
C++ beginner problem
8 ответов
0
Normal one resolving eq second degrees
0
#include<iostream>
#include<math.h>
using namespace std;
int main()
{ float a,b,c,x1,x2,delta;
cout << "a="; cin >> a;
if (a==0) cout<<"erreur math";
else {cout<<"new value a:"; cin>>a;}
cout << "b=";cin >> b;
cout << "c=";cin >> c;
delta = b*b-4*a*c;
cout<<"Delta="<<delta<<endl;
cout<<"put another value for a";
delta = b*b-4*a*c;
cout<<"Delta="<<delta;
if(delta<0) cout<<"pas de solution";
else if(delta==0);
cout <<"x1=x2="<< -b/(2*a);
if(delta>0)cout<<"Delta="<<delta;
else {
x1=(-b-sqrt (delta))/(2*a) ;
x2=(-b+sqrt(delta))/(2*a);
cout<<"x1="<<x1;
cout<<"x2="<<x2;
}
}
0
Also it not verify if a ==0 I don t know how to fix it any idea???
0
I think I must add instructions here for that make sens because I want the code to stop when it found a=0
0
Tkx a lot
0
Ok
- 1
Ok tkx
- 1
Or just recommand the user to put another value of a and continue the program for step I don't know how to make it