I tried to solve the program for a look and read digit. The user input a number like 488667 and the result of the program should be 14282617 with no function,array, or pointer used. To solve the program I get an error which is that the counter does not cumulate.Please if somebody have any suggestions I would appreciate it.
Code:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int m,c,i,n;
int counter=0;
cout<<endl<<endl;
cout<<" Please enter number"<<endl;
cin>>n;
int s =log10(n);
for(i=s;i>=0;i--)
{
c=pow(10,i);
m=(pow(10,(s-i)));
if(((n/(c))%10)==((n/(c/10))%10))
{
counter+=1;
}
cout<<counter<<(n/c)%10;
if(((n/(c))%10)!=((n/(c/10))%10))
cout<<"1"<<(n/c)%10;
}
return 0;
}
Thanks.