Lucky Four | Problem - 35 | Beginner level | C language | CodeChef
Link to the problem statement: https://www.codechef.com/submit-v2/LUCKYFR
Solution:
#include <stdio.h>
int main(void) {
int t, i, x, k;
scanf("%d", &t);
for(i=0;i<t;i++)
{
scanf("%d", &x);
k = 0;
while(x != 0)
{
if(x%10 == 4)
k++;
x = x/10;
}
printf("%d\n", k);
}
return 0;
}
Hope this will help you, if you want anything else leave a comment.
Thank you
Comments
Post a Comment