0
How does this code work?
unsigned sq(short a){ return a*a; } int main(){ long double x = 1.9; short r(sq(x)); cout <<r; } //is unsigned a function of some sort (like main()) //is short the exact opposite of long in the code? //how can you use 2 parameters long and double at same time. someone plz explain how this works.
2 Answers
+ 3
This gives the typical memory allocation for various standard types.
https://en.cppreference.com/w/cpp/language/types
0
I didn't know that unsigned by itself worked as a type, because you should know which type is unsigned - int or double or float. unsigned is exactly what it sounds like; usually a number includes negative and positive values, but when declared unsigned it doubles the number of values it can have, as long as it's positive. long just describes the precision, so it can also be used for int. I may be wrong, but I think double is a 'long float'. long increases the number of values while short decreases them. I'm sure you could find it with a Google search.



