PracticeDev/study_cpp/cpp_primer_source_code/Chapter 3/modulus.cpp

19 lines
507 B
C++
Raw Normal View History

2022-12-20 17:31:11 +08:00
// modulus.cpp -- uses % operator to convert lbs to stone
#include <iostream>
int main()
{
using namespace std;
const int Lbs_per_stn = 14;
int lbs;
cout << "Enter your weight in pounds: ";
cin >> lbs;
int stone = lbs / Lbs_per_stn; // whole stone
int pounds = lbs % Lbs_per_stn; // remainder in pounds
cout << lbs << " pounds are " << stone
<< " stone, " << pounds << " pound(s).\n";
// cin.get();
// cin.get();
return 0;
}