I am writing a program using mathematical operators for a book. There was a question (which may have already been asked): how correctly in the if condition, should the b symbol be replaced with ENTER? Tell me please.
#include "stdafx.h" #include <iostream> #include <conio.h> #include <cstdlib> #include <ctime> using namespace std; #define PRINT(STR, VAR) \ cout << STR " = " << VAR << endl; int main() { int i, j, k; float u, v, w; char c = 0; while(true){ cout << "enter an integer: "; cin >> j; cout << "enter another integer: "; cin >> k; PRINT("j", j); PRINT("k", k); i = j + k; PRINT("j + k", i) i = j - k; PRINT("j - k", i) i = k / j; PRINT("k / j", i) i = k * j; PRINT("k * j", i) i = k % j; PRINT("k % j", i) j %= k; PRINT("j %= k", j); _getch(); system("cls"); cout << "Enter a floating-point number: "; cin >> v; cout << "Enter another floating-point number: "; cin >> w; PRINT("v", v); PRINT("w", w); u = v + w; PRINT("v + w", u); u = v - w; PRINT("v - w", u); u = v * w; PRINT("v * w", u); u = v / w; PRINT("v / w", u); u += v; PRINT("u += v", u); u -= v; PRINT("u -= v", u); u *= v; PRINT("u *= v", u); u /= v; PRINT("u /= v", u); _getch(); cout << endl; cout << "Would you like to try again? " << endl; cout << "if YES than press 'b'" << endl; cout << "if NO than press 'q' " << endl; cin >> c; if (c == 'q'){ break; } else if(c == 'b'){ system("cls"); continue; } } _getch(); return 0; }
'\n'? Or are you not about that? - AnTwhile? - AnT