Help me in solving LUCKYFR problem

My issue

When I tried it using nested while loop is displayed Time limit exceeded. How can we solve it without using loops?

My code

#include <stdio.h>

int main(void) {
	// your code goes here
	int t,i=0,count=0;
	scanf("%d",&t);
	while(i<t){
	    int n;
	    scanf("%d",&n);
        while(n>=0){
	    int ld=n%10;
	        if(ld==4){
	          count++;
	        }
	       n/10;
	    }
	printf("%d",count);
    
}
	return 0;
}


Problem Link: LUCKYFR Problem - CodeChef

@sunnygupta9968 You can simply solve this problem by taking the numbers as string and then match how many ‘4’ are present in each.

Here is my code for reference.

# cook your dish here
for _ in range(int(input())):
    t=input()
    c=0
    for i in t:
        if(i=='4'):
            c+=1
    print(c)