https://rentry.org/PPP2_p116 ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15// Code derived from Stroustrup's PPP2 book // § 4.5.1 Why bother with functions? // -and beginning on p 116 #include <iostream> using std::cout; void print_square(int v) { cout << v << '\t' << v * v << '\n'; } int main() { for (int i = 0; i < 100; ++i) print_square(i); } build & run: g++ -std=c++20 -O2 -Wall -pedantic ./ch_04/main_p116.cpp && ./a.out sauce: Bjarne Stroustrup's PPP2 textbook /robowaifu/'s official C++ learning textbook thread Prev • Up • Next