I understand what the declaration "unsigned int" means - it simply means that you are going to use only +ve integers starting from 0. But I don't understand what this "unsigned char" and "signed char" declarations are.
Here is ASCII table. Normal ASCII runs from 0 to 127 (decimal) and the extended from 0 to 255 (decimal).
Please have a look on the below given codes which only differ in the declarations of the variables. The first one has unsigned char and the second signed char.
The output for both is "f" which has ASCII decimal value 102. So, please now help me to understand what's going on and how the two declarations differ?
#include <iostream>
using namespace std;
int main()
{
unsigned char a = 100;
unsigned char b = a + 59;
cout << "enter a = ";
cin >> a;
cout << b << endl;
system("pause");
}
Output from the Command Prompt:
enter a = 100 ƒ Press any key to continue . . .
#include <iostream>
using namespace std;
int main()
{
signed char a = 100;
signed char b = a + 59;
cout << "enter a = ";
cin >> a;
cout << b << endl;
system("pause");
}
Output from the Command Prompt:
enter a = 100 ƒ Press any key to continue . . .


Sign In
Create Account


Back to top









