what's wrong with this code? It's supposed to get a digit from me, then show all the numbers between 100 & 1000000 containing that digit...
#include <stdio.h>
int main () {
int n,m;
puts("Enter your digit:\n");
scanf("%d\n", n);
int j=100;
while (j<=1000000) {
m=10;
if (j%m==n) {printf("%d\n",j);}
while (j/m>=1) {
if ((j/m)==n) {printf("%d\n",j);}
m=m*10;}
j =1;}
return 0;
}
CodePudding user response:
When using scanf use the '&' sign after the comma. And it is wise to avoid using '\n' inside scanf; so it should look like this: scanf("%d", &n);
CodePudding user response:
Try using this code and see how it works
#include <stdio.h>
#include <math.h>
int main () {
int n,m;
puts("Enter your digit:\n");
scanf("%d", &n);
for(int i = 1;(pow(10,i)*n)<1000000;i )
{
for(int j = 0;j<(pow(10, i));j )
printf("%lf\t\t", ((pow(10, i)*n)) j);
printf("\n");
}
return 0;
}