C++ relative numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

C++ relative numbers

here there is my programm but when a result should be negative the programm show 0, further more i have only round numbers, and i would like to have some specific numbers. Someone can help me please ;) #include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int a; int b; int c; cout<< "Entrez a\n"; cout<< "Entrez b\n"; cout<< "Entrez c\n"; cin >> a >> b >> c; int delta = (b*b)-(4*(a*c)); int racine_carre_de_delta = sqrt(delta); cout<< delta<<endl; if (delta > 0) { int x1= ((-b-racine_carre_de_delta)/(2*a)); int x2= ((-b+racine_carre_de_delta)/(2*a)); cout<< "Deux solutions\n"; cout<< fixed<< setprecision (9)<< x1<<endl; cout<< fixed<< setprecision (9)<< x2<<endl; } if (delta == 0) { int x1bis= (-b/(2*a)); cout<< "Une solution\n"; cout<< fixed<< setprecision (9)<< x1bis<<endl; } if (delta < 0){ cout << "Pas de soltution"; } return 0; }

17th Feb 2019, 11:08 AM
1 Answer
a clue i thinks better lol Unsigned Integer Types unsigned short, unsigned int, unsigned long, and unsigned long long there is signed types. as for accuracy can an int hold a decimal place like a real number a floating decimal place. rounded up or down may be implicated by the types of data we use i guess lol
17th Feb 2019, 11:35 AM
peter - avatar