https://rentry.org/PPP2_p178

// Code derived from Stroustrup's PPP2 book
// § 6.3 Back to the calculator!
//  -and beginning on p 178

#include <iostream>

using std::cout;

int main()
{
  cout << (2 + 2) << '\n';           // 4
  cout << (2 + 2 * 3) << '\n';       // 8
  cout << (2 + 3 - 25 / 5) << '\n';  // 0
}

build & run:

g++ -std=c++20 -O2 -Wall -pedantic ./ch_06/main_p178.cpp && ./a.out

PrevUpNext

Edit
Pub: 13 Mar 2023 03:49 UTC
Edit: 30 Apr 2023 07:16 UTC
Views: 356