Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c float precision

#include <stdio.h>

int main (){
    float a;
    printf("
Enter a real number here please: ");
    scanf("%f",&a);
    
    printf("
Printing Number with different precision: ");
    printf("
  Number default precision: %f", a);
    printf("
  Number in (0 d.p.): %.0f", a);
    printf("
  Number in (1 d.p.): %.1f", a);
    printf("
  Number in (2 d.p.): %.2f", a);
    printf("
  Number in (3 d.p.): %.3f", a);
    printf("
  Number in (3 d.p.): %.4f", a);
    return 0;
}
 
PREVIOUS NEXT
Tagged: #float #precision
ADD COMMENT
Topic
Name
8+6 =