https://rentry.org/PPP2_p116

// 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

PrevUpNext

Edit
Pub: 04 Feb 2023 04:57 UTC
Edit: 29 Apr 2023 08:30 UTC
Views: 627