How to find digits after decimal? [closed]
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I want to write a program in C++ to cin a Decimal number and cout the digits after Decimal for example 0.26547 -> 5. I wrote this but not work correctly: int main() { int i=0,b; float a ; cin>>a ; while(a!=0) { a*=10 ; b=a ; a-=b ; i+=1 ; } cout<<i ; } For example for 0.258 instead of 3, returns 20. can one