I'm trying to get the last digit of entered value in C++. Why the output is always 7 or 5 when I enter a big number e.g. 645177858745?
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "Enter a number: ";
cin >> a;
a = a % 10;
cout << "Last Number is " << a;
return 0;
}
Output:
Enter a number: 8698184618951
Last Number is 5