If a 4 digits number is entered from keyboard, write a program that should subtract the last digit from the first digit and display the result.

#include <iostream>
using namespace std;
int main()
{
int x,n,rem;
cout<<“Enter an integer: “;
cin>>n;
x=n%10;
n=n/10;
while(n!=0)
{
rem=n%10;
n=n/10;
}
n=rem-x;
cout<<n;
return 0;
}