6 questions. Covers Pure functions.
Questions 1 to 5 of 6
cpp int offset = 2; int shifted(int x) { return x + offset; }
cpp int next_ticket_pure(int counter) { return counter + 1; }
cpp #include <iostream> int offset = 2; int shifted(int x) { return x + offset; } int main() { std::cout << shifted(5) << ' '; offset = 4; std::cout << shifted(5) << ' ' << shifted(5) << '\n'; }
cpp #include <iostream> int next_ticket() { static int counter = 0; return ++counter; } int next_ticket_pure(int counter) { return counter + 1; } int main() { std::cout << next_ticket() << ' ' << next_ticket() << ' ' << next_ticket() << '\n'; std::cout << next_ticket_pure(7) << ' ' << next_ticket_pure(7) << '\n'; }
price
tax_rate
5 question(s) left on this page.