Print reverse problem

please tell the errors in my code of print reverse problem?

you have to declare the rev variable outside while loop
like this

#include<iostream>
using namespace std;

int main() {
	int num;
	cin > num;
	int rev = 0;
	while (num)
	{
		int n;
		n = num % 10;
		num = num / 10;
		rev = rev * 10 + n;

	}
	cout << rev << endl;
	return 0;
}

this code is showing tle

as mention in the constraints the number is very large
so instead of int use long long int
like this

#include<iostream>
using namespace std;

int main() {
	long long int num;
	cin >> num;
	long long int rev = 0;
	while (num)
	{
		int n;
		n = num % 10;
		num = num / 10;
		rev = rev * 10 + n;

	}
	cout << rev << endl;
	return 0;
}

understood the code
send me the feedback

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.