write a program to find out the sum of all the digits of a floating point number. you need to sum all the digits before decimal and after decimal

#include <stdio.h> 
void main() 

float f; 
//enter the float number 
printf("Enter a floating point number :");
scanf("%f",&f); 
//float number in integer 
long long temp=f*1000000; 
int sum=0; 
    while(temp!=0) 
    { 
    //remainder of the temp value 
    int rem=temp%10; 
    sum=sum+rem; 
    temp=temp/10; 
 
    }     
    //sum of all the digits 
    printf("Sum of all digits of is %d\n",sum );   



Comments