How many digits after decimal point can be determined?

By using C program

In this using a variable as format specifier

PROGRAM: 
#include<stdio.h>
main(){
    float a;
    int b;
    printf("\nEnter Float Number: ");
    scanf("%f",&a);
    printf("\nHow many digit needed after decimal point: ");
    scanf("%d",&b);
    printf("\nOUTPUT: %.*f",b,a);
}




Instead of  %.*f in  , we can also directly give the number like %.2f , which round off for above example will be 12.12 

Comments

Popular Posts