Program to set limit of number after point (.) in floating value.

In this  program we have to set limit ( How many number should present after point (.) ) .

example:-  
            4.000 is a floating value in this after point there are 3 zero but we want only one then we have  to fix number after point.

example 2:-
                   if we have to add two floating  number 2.0 and 4.0 then when we add in compiler
the ans is 6.0000 but we want only 6.0 then we have to set limit . So for set limit in printing statement we have to write (%0.0f) when we want no any number after point .(% 0.1f) if we want one number after point.(%0.2f) for two and so on.

#include<stdio.h>
void main()
{
float a,b,sum;
scanf(“%f%f”,&a,&b);
sum=a+b;
printf(“%0.1f”,sum);
}

    

2 thoughts on “Program to set limit of number after point (.) in floating value.

Leave a Reply

Your email address will not be published.