I am working on an assignment and am having problems with one of the questions. The question is : What is the magnitude of the largest value you can place in a bool? a char? an int? a float? a double?
So i made the following program in hopes of finding those answers:
what do you mean? your not doing anything wrong. int's max for your os is 2147483647. chars max is whatever the ascii value of ⌂ is. floats max is 3.40282 x 10^38 (i think thats how you read that). and double is 1.79769 x 10^308 (once again that might be the wrong way to read it). bool doesnt really have a max. its one value true or false, so its a little different. cout<< sizeof(true) might work
I wasn't sure how to interpret the X value and assumed once I saw that strange symbol that I had made a mistake considering how sloppy the other values look. I now see what you are talking about and would like to thank you for your help.
no problem. we all make mistakes. http://www.asciitable.com/ thats a link to an ascii chart. chars actually hold int values and then the compiler turns that into a character. so if you did char mychar = 99; and then print it you will see it print a c
It looks like correct output? The X = ⌂ - I assume that is the highest value char character. You could find its numerical value by just doing int y = X; . You can get higher values stored if you declare integers or chars as unsigned.