From 1e4270a7110858d6f5d4cdf12f37d78dc81bc7d9 Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 30 Aug 2024 19:48:45 +0200 Subject: more --- 5p18.cpp | 35 +++++++++++++++++++++++++++++++++++ 5p19.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 5p18.cpp create mode 100644 5p19.cpp diff --git a/5p18.cpp b/5p18.cpp new file mode 100644 index 0000000..eb6ea7f --- /dev/null +++ b/5p18.cpp @@ -0,0 +1,35 @@ + +/* + * + * 5.18 + * + * + */ + +int main () { + + /* + (a) Corrected versions + + do { + int v1, v2; + cout << "Please enter two numbers to sum:" ; + if (cin >> v1 >> v2) + cout << "Sum is: " << v1 + v2 << endl; + } while (cin); + + (b) + int ival; + do { + // . . . + } while (ival = get_response()); + + (c) + int ival; + do { + ival = get_response(); + } while (ival); + + */ + return 0; +} diff --git a/5p19.cpp b/5p19.cpp new file mode 100644 index 0000000..5d59ddb --- /dev/null +++ b/5p19.cpp @@ -0,0 +1,31 @@ +#include + +/* + * + * 5.19 + * + * + */ + +int main () { + + std::string keepgoing; + do { + std::cout << "Enter two strings" << std::endl; + std::string s1; + std::string s2; + std::cin >> s1 >> s2; + if(s1 > s2) { + std::cout << "s1 > s2" << std::endl; + } else if (s2 > s1) { + std::cout << "s2 > s1" << std::endl; + } else if (s1 == s2) { + std::cout << "s1 == s2" << std::endl; + } + + std::cout << "Continue?" << std::endl; + std::cin >> keepgoing; + } while(keepgoing == "Y" || keepgoing == "y"); + + return 0; +} -- cgit v1.2.3