For my C++ class my teacher wanted us to create a dividing calculator, that we would use the define DBL figure's to create the division table outline that has the answer display on top and the dividend and divisor on the side and inside (below the answer. The promblem I am having is when i printf or cout the DBL's it just displays the numbers not the ascii's, I have tried it on reverse with the number and still doesn't display them. Below is the code I am using. Any other way that I could try displaying them?
// Declare Variables
// Prompt User For Needed Inputs
// Perform Necessary Mathematical Calculations
// Display Results
// It's Over!
int a, b, r, q;
std::cout << "Enter a value for the dividend: ";
cin >> b;
cout << "Enter a value for the divisor: ";
cin >> a;
r = b % a;
q = b / a;
cout << q << " R " << r << endl;
#define is the old C way of making constants within your code. It is not type-aware, and has no idea it's supposed to interpret those numbers as text characters; it simply replaces the tokens with the given number. There's no point in using it in modern C++ for constants.
Note that those characters, strictly speaking, aren't ASCII, but are extended ASCII. I think what's actually printed out depends on whether or not the console is set to interpret the characters as extended ASCII (as opposed to Latin-1 or UTF-8, etc.). Regardless, it shouldn't hurt to make them be unsigned chars instead of just chars. I believe on Windows it will print what you expect by default, but I'm not sure about Mac/Linux.
PS: In future topics, please note that a title like "C++ HELP" is not informative. A better title would be "Can't print ascii values in dividing calculator" or something like that.
here, I would have used an enum most likely. (Why: these look like they belong together and could use a 'we belong together grouping structure' which enum provides, a namespace would as well if you prefer).