From bfa29c55fd58912845b5a6684489231a4d4e675e Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 16 Aug 2024 19:00:04 +0200 Subject: more exercises --- 4p5.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 4p5.cpp (limited to '4p5.cpp') diff --git a/4p5.cpp b/4p5.cpp new file mode 100644 index 0000000..abeefdd --- /dev/null +++ b/4p5.cpp @@ -0,0 +1,32 @@ +#include + +/* + * + * 4.5 + * + * + */ + +int main () { + + int res_a = -30 * 3 + 21 / 5; + int res_b = -30 + 3 * 21 / 5; + int res_c = 30 / 3 * 21 % 5; + int res_d = -30 / 3 * 21 % 4; + int p_res_a = ((-30 * 3) + (21 / 5)); // -86 + int p_res_b = (-30 + ((3 * 21) / 5)); // -18 + int p_res_c = (((30 / 3) * 21) % 5); // 0 + int p_res_d = (((-30 / 3) * 21) % 4); // -2 + + std::cout << res_a << "\n" + << res_b << "\n" + << res_c << "\n" + << res_d << "\n" << std::endl; + + std::cout << p_res_a << "\n" + << p_res_b << "\n" + << p_res_c << "\n" + << p_res_d << "\n" << std::endl; + + return 0; +} -- cgit v1.2.3