centralized performance resources

This commit is contained in:
Barrett Ruth 2026-01-10 12:21:52 -05:00
commit 50b15a1522
63 changed files with 328466 additions and 0 deletions

20
perf-cpp/scripts/ch6.cc Normal file
View file

@ -0,0 +1,20 @@
#include <iostream>
#include <cstdint>
/*
Write a program that asks the user to input an integer, and tells the user whether the number is even or odd. Write a constexpr function called isEven() that returns true if an integer passed to it is even, and false otherwise. Use the remainder operator to test whether the integer parameter is even. Make sure isEven() works with both positive and negative numbers
.*/
constexpr bool isEven(std::int32_t number) {
return number % 2 == 0;
}
int main() {
std::cout << "input an integer: \n";
std::int32_t x{};
std::cin >> x;
std::cout << std::boolalpha << isEven(x);
return 0;
}