Concept behind one of the quiz questions

i didnt understand the concept behind one of the quiz question.
the question is as follows:
Predict the output-
long signed CodingBlocks = 2017;
short unsigned BOSS1 = -2018;
unsigned BOSS2 = -2019;
int BOSS3 = -2020;
long long unsigned BOSS4 = -2021;
short unsigned Nagarro = 2018.9;
long signed HackerBlocks = ‘A’;
cout<<CodingBlocks<<endl;
cout<<BOSS1<<endl<<BOSS2<<endl<<BOSS3<<endl<<BOSS4<<endl;
cout<<Nagarro<<endl;
cout<<HackerBlocks<<endl;

i do not know how to think for questions like these. My answer was completely different and i myself couldn’t make up an answer as to why compiler is giving such an output!

hey Varinda, this question checks whether datatype assigned to variable is correct to store the value assigned to variable or not.

Signed means number can be positive as well as negative, so it just print the value as it is in cout (check for CodingBloocks).

Unsigned means variable can have positive values only.

int BOSS3 is by default signed int so it prints as it is in cout.

BOSS2,BOSS4 has negative number but it is unsigned i.e they cannot be negative hence they are giving maximum number in there range.

Signed and Unsigned modifier are not available for floating value So Nagarro is treated as int only.

if you want to use Signed or unsigned for characters than it should be Signed char or signed char, if you use only signed and unsigned char than it will be treated as integer and gives ASCII value of that Character(see for Hackerblocks) .

If you want to know about range of these modified datatypes, check this link https://fresh2refresh.com/cpp-tutorial/cpp-data-types-modifiers/