kns2872,
The program in your OP has the right idea once you clean up the errors. The variables: rate, integer, counter, totalint, distance, accuracy and temp are all undefined variables. Not sure what you wanted to do with these variables. So, for now I just commented them out until a later time when I understand how you wanted to use them. Line 25 tries to redefine line 23. Make those two different names and give each a type of
char
for the variables
charsymbol
and the 3 on line 25 should be enclosed in at least single quotes snice it should be of type
char
.
Here are the changes I made. I added some formatting to make the output easier to read. Compare it to your original program and notice the differences:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
cout << "Program 2A" << endl;
cout << "Kaitlin Stevers" << endl;
cout << "September 5, 2016" << endl;
cout << "Demonstratinn of variable types, storage sizes and max/min values." << endl;
int count = 42;
cout << "\n name\t\ttype\t\t\t storage size\t\tmin/max values\n" << endl;
cout << left << setw(10) << " rate \t\tshort \t\t\t\t" << setw(2) << sizeof(short) << "\t" << /*rate <<*/ "\t" << SHRT_MIN << " to " << SHRT_MAX << "n" << endl;
cout << left << setw(10) << " count \t\tint \t\t\t\t" << setw(2) << sizeof(int) << "\t" << /*int <<*/ "\t" << INT_MIN << " to " << INT_MAX << "\n" << endl;
cout << left << setw(10) << " counter \tlong int \t\t\t" << setw(2) << sizeof(long int) << "\t" << /*counter <<*/ "\t" << LONG_MIN << " to " << LONG_MAX << "\n" << endl;
cout << left << setw(10) << " totalint \tunsigned int \t\t\t" << setw(2) << sizeof(unsigned int) << "\t" << /*totalint <<*/ "\t" << UINT_MAX << "\n" << endl;
cout << left << setw(10) << " distance \tfloating point \t\t\t" << setw(2) << sizeof(float) << "\t" << /*distance <<*/ "\t" << FLT_MIN << " to " << FLT_MAX << "\n" << endl;
cout << left << setw(10) << " accuracy \tfloating point double\t\t" << setw(2) << sizeof(double) << "\t" << /*accuracy <<*/ "\t" << DBL_MIN << " to " << DBL_MAX << "\n" << endl;
cout << left << setw(10) << " temp \t\tfloating point long double \t" << setw(2) << sizeof(long double) << "\t" << /*temp <<*/ "\t" << LDBL_MIN << " to " << LDBL_MAX << "\n" << endl;
char charsymbol = 'r';
cout << " charsymbol \tcharacter \t\t\t" << sizeof(char) << "\t" << charsymbol << "\t" << CHAR_MIN << " to " << CHAR_MAX << "\n" << endl;
char charsymboli = '3';
cout << left << setw(10) << " charsymbol \tcharacter \t\t\t" << sizeof(char) << "\t" << charsymboli << "\t" << CHAR_MIN << " to " << CHAR_MAX << "\n" << endl;
cout << left << setw(10) << " flag \t\tboolean \t\t\t" << sizeof(bool) << "\t" << /*flag <<*/ "\t" << "0" << " to " << "1" << "\n" << endl;
|
Hope that helps,
Andy
P.S. If you write your own tags to surround your code it starts with
code
surrounded with square brackets and the closing is
/code
surrounded by square brackets. You missed the fordward slash o your second code posting. Or you can highlight your code and press the
<>
to the right of the message box.