You are inputting a coded character into symbol, not an integer. When you cin into a char, it will capture a coded character from the user rather than a numerical value ze inputs.
cin >> symbol;
What is a coded character?
According to Wikipedia, "code is a system of rules to convert information—such as a letter, word, sound, image, or gesture—into another form or representation." There are many different ways of representing glyphs used in human language, such as numerals, as numbers inside a computer. These ways are called character sets or encodings. Examples of character sets are SHIFT-JIS, ASCII, Unicode, and EBCDIC. These encodings are able to state that a glyph, say A, is equal to the number 65. It does so with every glyph it supports so that each glyph has a unique number.
How does this relate to my issue?
Well... assuming that your environment uses the ASCII character set, and your user inputs a 0, the number your program is going to receive is NOT going to be 0. Instead, it is going to be 48. This is an issue because your program is checking for the number 0. Please note that different environments can have different character encodings with different values for different glyphs. Most character sets (but not all!) tend to agree with ASCII on the basic Latin alphabet and Arabic numerals, however.
} while (symbol != 0);
How do I fix this?
The solution is very simple. All you have to do is surround the zero you are checking for with single quotes. This will cause your program to check symbol for the coded representation of the zero glyph your user input rather than the numerical value of zero.
} while (symbol != '0');
What else do I need to know?
The char data type actually isn't that special. It's a number just like the rest of the data types. It was intended for storing character values, however. Variables of type char are one byte wide. If a byte is 8 bits, that means that a signed char can store any number from -128 to 127. You can treat char variables exactly the same as any other scalar integer type in C++. So what your char is actually holding is just a number. Nothing more, nothing less.
The definition of code came from https://en.wikipedia.org/w/index.php?title=Code&oldid=823846736.
'0', not0.symbolis a character. Now how is the digit 0 represented as achar?num2will be left in the input buffer, to be read by the nextcin >> symbol. You need to ignore everything up to the next newline in your input after the last input in the loop.breakafter you enter symbol like this:std::cin >> symbol; if (symbol == '0') break;