C++ examples for Operator:Arithmetic Operator
Converting a length in inches to feet-and-inches.
#include <iostream> int main(){//from w ww . ja va2 s . c om const int inches_per_foot = 12; long length_inches = 0; std::cout << "Please enter the number of inches: "; std::cin >> length_inches; long feet = length_inches / inches_per_foot; long inches = length_inches % inches_per_foot; std::cout << "In " << length_inches << " inches there are " << feet << " feet and " << inches << " inch(es)." << std::endl; }