My code is not running. LUCKFOUR

Impressed by the power of this number, Kostya has begun to look for occurrences of four anywhere. He has a list of T integers, for each of them he wants to calculate the number of occurrences of the digit 4 in the decimal representation. He is too busy now, so please help him.

INPUT-

The first line of input consists of a single integer T, denoting the number of integers in Kostya’s list.

Then, there are T lines, each of them contain a single integer from the list

Output

Output T lines. Each of these lines should contain the number of occurences of the digit 4 in the respective integer from Kostya’s list.

/NO OUTPUT GIVEN BY MY CODE BELOW pls HELP…/

#include <stdio.h>
int main(){
int n,i,num,sum=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&num);
for(num;num%10!=0;num/10){
if(num%10==4)
sum++;
}printf("%d",sum);
sum=0;
}return 0;
}

Hi Buddy, your code is running but got stuck into infinite loop because of decrement condition (line 7). Your logic is correct, use num/=10 instead of num/10.

Pay attention to compiler warnings!

[simon@simon-laptop][12:07:27]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling cloudy6-LUCKFOUR.cpp
Executing command:
  g++ -std=c++17 cloudy6-LUCKFOUR.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG    -fsanitize=undefined -ftrapv
cloudy6-LUCKFOUR.cpp: In function ‘int main()’:
cloudy6-LUCKFOUR.cpp:7:13: warning: statement has no effect [-Wunused-value]
    7 |         for(num;num%10!=0;num/10){
      |             ^~~
cloudy6-LUCKFOUR.cpp:7:30: warning: value computed is not used [-Wunused-value]
    7 |         for(num;num%10!=0;num/10){
      |                           ~~~^~~
cloudy6-LUCKFOUR.cpp:4:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    4 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
cloudy6-LUCKFOUR.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    6 |         scanf("%d",&num);
      |         ~~~~~^~~~~~~~~~~
Successful