0

What is the error in my c code

#include <stdio.h> int main () { int n, count = 0, rem, t, l, r, i; scanf ("%d", &t); while (t--) { scanf ("%d",&l); scanf ("%d",&r); if(r<4444)printf("0"); for (i=4444;i<=r;i++) { n=i; printf("%d\n",n); while (n != 0) { rem = n % 10; if (rem == 4 || rem == 7) ++count; i /= 10; } //printf("Number of digits: %d", count); if (count == 4 || count == 7) printf ("lucky number"); else printf ("not lucky number"); } } return 0; }

18th Jul 2018, 4:22 PM
Bala Krishna
Bala Krishna - avatar
3 Respostas
+ 1
This is not a java code
19th Jul 2018, 12:16 AM
Paul Yan
Paul Yan - avatar
+ 1
#include <stdio.h> int main () { int n, count, rem, t, l, r, i; scanf ("%d", &t); while(t--) { scanf("%d",&l); scanf("%d",&r); if(r < 4444) { printf("Lucky number starts from 4444\n"); continue; } if(l >= r) { printf("Invalid search range %d ~ %d\n", l, r); continue; } for(i = l; i <= r; ++i) { n = i; count = 0; //printf("%d\n", n); while (n) { rem = n % 10; if (rem == 4 || rem == 7) ++count; n /= 10; } //printf("Number of digits: %d", count); if (count == 4 || count == 7) printf ("%d Lucky number\n", i); //else // printf ("%d Not lucky number\n", i); } } return 0; }
19th Jul 2018, 4:44 AM
Ipang
0
Bala Krishna where did you see this way to check lucky number? lucky number theory in wiki is different ...
19th Jul 2018, 4:46 AM
Ipang