Ich kenne nicht den Grund, warum der Schwimmer nicht den genauen Wert druckt, wenn ich dieses Programm ausführe.Float funktioniert nicht richtig
#include <iostream>
using namespace std;
int main(){
int a, b;
float x;
cout << "Input the value for a: ";
cin >> a;
cout << "Input the value for b: ";
cin >> b;
x = - b/a;
printf("The value of x is: %.2f",x);
//cout << "The value of x is: " << x;
}
Ich möchte zumindest wenn ich Eingang 2 für a und 10 für b das Ergebnis 0,20 sein sollte, zeigt das Programm 0,00 nur
nicht '\\' ergibt Quotient. also Ergebnis wird immer noch 5 – jonju
so kann ich Float Antworten wie 1.5 nicht bekommen, wenn meine Operanden Ganzzahlen sind? – Marr