+ 2
I need help š I'm new to c++ and I'm stuck
I try to print a floating point number, for example double number = 1/2; cout <<number ;//output is 0 instead of 0.5 Why does the compiler take the whole number and keeps out the decimals But on the other hand, double number = 0.5;// output is 0.5 I'm confused I KNOW THIS IS MERE BASICS BUT PLS DON'T SKIP š
3 Answers
+ 3
FF9900 thanks for the help, it helped me solve my third challenge, ticket office in c++
0
#include <iostream>
using namespace std;
int main() {
float a=1.0/2.0;
cout<<"input one number "<<endl;
cout<<a; //Output=0.5
return 0;
}