#include <iostream>
using namespace std;
int main()
{
float a;
cin>>a;
int sum = 0 ,b = a*100;
while (b > 0)
sum+=b%10;
b=b/10;
}
cout<<"sum = "<<sum;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main()
{
float a;
cin>>a;
int sum = 0 ,b = a*100;
while (b > 0)
{
sum+=b%10;
b=b/10;
}
cout<<"sum = "<<sum;
return 0;
}