Solved: 04 - Variables and Types

This commit is contained in:
2026-08-12 08:56:24 +03:00
parent 2d25dd503a
commit d9c7987269
@@ -1,43 +1,38 @@
#include "variables_and_types.hpp" #include "variables_and_types.hpp"
#include <sstream>
namespace fundamentals { namespace fundamentals {
auto add_integers(int lhs, int rhs) -> int { auto add_integers(const int lhs, const int rhs) -> int {
// TODO: Return the sum. return lhs + rhs;
(void)lhs;
(void)rhs;
return 0;
} }
auto multiply_doubles(double lhs, double rhs) -> double { auto multiply_doubles(const double lhs, const double rhs) -> double {
// TODO: Return the product. return lhs * rhs;
(void)lhs;
(void)rhs;
return 0.0;
} }
auto is_even(std::int64_t value) -> bool { auto is_even(const std::int64_t value) -> bool {
// TODO: Return true when value is divisible by 2. return value % 2 == 0;
(void)value;
return false;
} }
auto describe_type(int value) -> std::string { auto describe_type(const int value) -> std::string {
// TODO: Return "int:" followed by the decimal representation. auto oss = std::ostringstream{};
(void)value; oss << "int:" << value;
return "int:0"; return oss.str();
} }
auto describe_type(double value) -> std::string { auto describe_type(const double value) -> std::string {
// TODO: Return "double:" followed by the value with one decimal place. auto oss = std::ostringstream{};
(void)value; oss << "double:" << value;
return "double:0.0"; return oss.str();
} }
auto describe_type(bool value) -> std::string { auto describe_type(const bool value) -> std::string {
// TODO: Return "bool:true" or "bool:false". auto oss = std::ostringstream{};
(void)value; const std::string representation = value ? "true" : "false";
return "bool:false"; oss << "bool:" << representation;
return oss.str();
} }
} // namespace fundamentals } // namespace fundamentals