Question #1165

Enter a number and find how many times the smallest digit occurred?

Expert's answer

#include <iostream>using namespace std;int main(){ int n; cout<<"Enter n..."<<endl; cin>>n; int counter=1; int k=n,m=0; n=n/10; while (n!=0) { m=n; n=n/10; if (m<k) { k=m; counter=1; } else if(m==k) counter++; } cout<<counter<<endl; system("pause");}

## Comments

## Leave a comment