https://rentry.org/PPP2_p100a

// Code derived from Stroustrup's PPP2 book
// § 4.3.3 Conversions
// -beginning on p 100

#include <iostream>

using std::cin;
using std::cout;

int main()
{
  cout << "Please enter a temperature centigrade: ";
  double dc;
  cin >> dc;

  // 9 / 5 * dc + 32 means ((9 / 5) * dc) + 32
  double df = 9 / 5 * dc + 32;  // beware!

  cout << df << '\n';
}

build & run:

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

PrevUpNext

Edit
Pub: 24 Jan 2023 05:51 UTC
Edit: 29 Apr 2023 06:49 UTC
Views: 620