Input
#include<iostream>
using namespace std;
int main()
{
int first, second;
int count=0;
do
{
cout<<"Please, enter an integer from 0-9: ";
cin>>first;
}while(first<0||first>9);
do
{
cout<<"Please, enter an integer : ";
cin>>second;
}while(second<0);
int tmpsec=second;
while(tmpsec>=0)
{
int temp = tmpsec%10;
if(temp==first)count++;
tmpsec=tmpsec/10;
if(tmpsec==0)break;
}
cout<<first<<" presents in "<<second<<" "<<count<<" times";
}
Comments
Leave a comment