// Code derived from Stroustrup's PPP2 book// § 4.4.1.1 if-statements// -and beginning on p 103#include<iostream>usingstd::cin;usingstd::cout;// convert from inches to centimeters or centimeters to inches// a whitespace-separated suffix ‘i’ or ‘c’ indicates the unit of the input// any other suffix is an errorintmain(){constexprdoublecm_per_inch=2.54;// number of centimeters in an inchdoublelength=1;// length in inches or centimeterscharunit=' ';// a space is not a unitcout<<"Please enter a length followed by a separate unit (c or i):\n";cin>>length>>unit;if(unit=='i')cout<<length<<"in == "<<cm_per_inch*length<<"cm\n";elseif(unit=='c')cout<<length<<"cm == "<<length/cm_per_inch<<"in\n";elsecout<<"Sorry, I don't know a unit called '"<<unit<<"'\n";}