Hi there i don't get this using cout and printf here's the code
why when using printf you can easily change the decimal places but why in cout??? for example i input number 11.50 the output goes like this.Code:#include <iostream> #include <stdio.h> #include <iomanip> #include <conio.h> using namespace std; int main(void) { float num; printf("input number: \n"); scanf("%f", &num); printf("The number is: %.2f\n", num); cout << setprecision (4) << "The number is: " << num << endl; getch(); }
why is that? cout can't print the last zero even if i use <iomanip>?Code:The number is 11.50 <--------------------------- using printf. The number is 11.5 <--------------------------using cout.
any idea there? thanks



LinkBack URL
About LinkBacks


