+ 3
In c programming, how to roundoff a floating point number as per the wish of the user.
for example i have a number a=1.3124, the user have to enter a number by himself upto which he wants to round off a number after decimal. if he enter n=2 the the no. printing in screen should be a=1.31 two digit after decimal.
1 Antwort
+ 16
Try this
int n; //no of decimals u want
float no= 3.456789;
scanf("%d",&n);
printf("%.*f",n,no);