fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main(){
  6. int num;
  7. int count;
  8. cout<<"Enter any number";
  9. cin>>num;
  10. while (num>0){
  11. if(num%10 == 1){
  12. count++;
  13. }
  14. num= num/10;
  15. }
  16. cout<<"Number of ones="<<count;
  17. return 0;
  18. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Enter any numberNumber of ones=-1218551806