centralized performance resources
This commit is contained in:
commit
50b15a1522
63 changed files with 328466 additions and 0 deletions
20
perf-cpp/scripts/ch6.cc
Normal file
20
perf-cpp/scripts/ch6.cc
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue