This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: denominator divided by space \n"; cin >> nom1 >> den1 >> nom2 >> den2; sum = (float)(nom1+nom2)/(den1+den2); // casting from int to float cout << "The sum is:\n"; cout << nom1 << "/" << den1 << "+" << nom2 << "/" << den2 << "=" << nom1+nom2 << "/" << den1+den2 << "or" << sum; return 0; } Problem 2 /* The program gets a number between 0 and 21,600 from the keyboard * and displays the number of hours, minutes and seconds */ # include <iostream> using namespace std; int main (void) { int number_of_sec, hours, minutes, seconds; cout << "Enter a number between 0 and 21,600\n"; cin >> number_of_sec; hours = number_of_sec/3600; minutes = (number_of_sec%3600)/60; seconds = (number_of_sec%3600)%60; cout << "The number of seconds entered is equivalent to:\n"; cout << hours << " hours " << minutes << " minutes and " << seconds << " seconds"; return 0; }...
View
Full Document
 Fall '08
 Bonev
 Division, Fractions, Fraction, #, Elementary arithmetic

Click to edit the document details