char(x) returns the character with the ASCII code number x. So, just if you enter 43, which is the ASCII code for '+', you will get "This is addition".
You cannot store characters in int data type, just ASCII code representing characters. Use char data type for character handling.
I want to keep the data type int. But I want to write a program that determines whether the user did enter a plus sign instead of a regular number. Is there a way to check to see if a data type int was entered as an addition sign?
I don't think so,entering a non-number value instead of a integer, will cause cin to fail. Instead, you can use char data type and check if character is number,or if it's non-number. http://www.cplusplus.com/reference/cctype/
#include <iostream>
int main()
{
int x ;
char c ;
bool number = false ;
std::cout << "Enter either a number or a character:";
std::cin >> c ; // read a char
// put it back and try to read a number
std::cin.putback(c) ;
if( std::cin >> x ) number = true ;
else
{
std::cin.clear() ; // clear the failed state (to enable more input)
x = c ;
}
if(number) std::cout << "This is the number " << x << '\n' ;
elseif( x == '+' ) std::cout << "This is addition\n" ;
else std::cout << "This is something else\n" ;
}