From 13c97461fde19829569dbe10f53322fef5909b83 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 12 Sep 2024 12:28:48 +0200 Subject: more --- 6p42.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 6p42.cpp (limited to '6p42.cpp') diff --git a/6p42.cpp b/6p42.cpp new file mode 100644 index 0000000..a2e1cca --- /dev/null +++ b/6p42.cpp @@ -0,0 +1,24 @@ +#include + +/* + * + * 6.42 + * + * + */ + +std::string make_plural(size_t ctr, + const std::string &word, + const std::string &ending = "s" + ) { + + return (ctr > 1) ? word + ending : word; +} + +int main () { + + std::cout << make_plural(2, "Success", "es") << std::endl; + std::cout << make_plural(2, "Success") << std::endl; + std::cout << make_plural(2, "Failure") << std::endl; + return 0; +} -- cgit v1.2.3