https://rentry.org/PPP2_p100b

// 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.0 / 5 * dc + 32 means ((9.0 / double(5)) * dc) + 32
  double df = 9.0 / 5 * dc + 32;  // better

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

build & run:

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

PrevUpNext

Edit
Pub: 24 Jan 2023 06:41 UTC
Edit: 29 Apr 2023 06:50 UTC
Views: 611