If a is an int, then cin>>a will read in characters from input until it can no longer use the characters to form a valid integer. In this case, it reads in 2 but stops at the '.' because you can't have a decimal point in an integer.
If you want a number that contains decimals, change a to be a double instead of an int. If you want your program to fail when it asks for an int but the user types a number with a decimal, you'll have to add another tweak:
That code reads into a, and then checks to see if there are any other characters after the integer. If the user types 2.45, then the cin.get() will get the decimal point, which isn't '\n'. If the user types in 68sdf8a6s, then it will read 68 into a and then fail because 's' is not '\n'. If they do it correctly and type 239, then cin.get() will get the newline from when they hit <enter>, and the read will succeed.Code:if ((cin >> a) && (cin.get() == '\n'))