How to separate integer and decimal part

CODE




How to separate integer and decimal part
int main()
{
    float num,a;
    int integer;
    printf("\n enter a number with 2 decimal digit:");
    scanf("\n%f",&num);
    integer=num;
    a= num-integer;
    printf("\n number=%f",num);
    printf("\n integer part=%i",integer);
    printf("\n decimal part=%f",a);
}


Output:
 enter a number with 2 decimal digit:
234.76543

 number=234.765427
 integer part=234
 decimal part=0.765427

How to separate integer and decimal part How to separate integer and decimal part Reviewed by Unknown on December 14, 2018 Rating: 5

No comments:

If you have any doubt or query ,comment below:

Programming copyright © 2018-19. Powered by Blogger.