// Code derived from Stroustrup's PPP2 book// § 4.4.1.2 switch-statements// -and beginning on p 105#include<iostream>usingstd::cin;usingstd::cout;intmain(){constexprdoublecm_per_inch=2.54;// number of centimeters in an inchdoublelength=1;// length in inches or centimeterscharunit='a';cout<<"Please enter a length followed by a separate unit (c or i):\n";cin>>length>>unit;switch(unit){case'i':cout<<length<<"in == "<<cm_per_inch*length<<"cm\n";break;case'c':cout<<length<<"cm == "<<length/cm_per_inch<<"in\n";break;default:cout<<"Sorry, I don't know a unit called '"<<unit<<"'\n";break;}}