I have this integer:
4732891432890432432094732089174839207894362154
It's big so I want to delete all digits in it except the digit 4 and I don't know how. This is my code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
unsigned ll n, lastDigit, count = 0;
ll t;
cin >> t;
while(t--)
{
cin >> n;
while (n !=0)
{
lastDigit = n % 10;
if(lastDigit == 4)
count++;
n /= 10;
}
cout << count << "\n";
}
return 0;
}
I used the while loop because I have multiple test case not only that number.