In the program i am converting the character datatype into integer but it is displaying the ASCII code of the character, why? what should i do to print 4 as output?
void fun(int x)
{
cout<<x;
}
int main()
{
char ch='4';
fun((int)ch);
return 0;
}
I have tried changing the parameter from 'int x' to 'char x' and then typecasting in cout as 'cout<<(int)x;'