Hi there i don't get this using cout and printf here's the code
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 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:
The number is 11.50 <--------------------------- using printf.
The number is 11.5 <--------------------------using cout.
why is that? cout can't print the last zero even if i use <iomanip>?
any idea there? thanks