0
#include <stdio.h> int main() { unsigned char x=300; printf("%d",x); }
Anyone please explain me the concept of unsigned
5 Answers
+ 7
unsigned char datatype range from 0 to 256. So, when you want to initialized 300, it takes it (300-256)=44.
That's why the result is 44
+ 7
Also after reading other answers, run this code.
You will get it what happens.
#include <iostream>
using namespace std;
int main() {
int i = 200;
for(unsigned char c = 200; c < 350; c++)
cout << "int: " << i++ << ", unsigned char: " << (int)c << "\n";
return 0;
}
+ 5
Generally data types goes from negative A-1 to positive A.
Unsigned free up first bit that is used for sign and doubles range of positive values.
for example if a Data type can take values from -127 to 128.
An unsigned Data type will go from 0 to 256.
+ 1
Thanks aparesh bhunia
0
The answer is 44 why?