Quote
# include <iostream> // for input/ output using namespace std; int numbers (string str) { int num; cout << str; cin >> num; while ( num <= 0 ) { cout << "Error !! Re-enter a positive, non-zero number. "; cin >> num; cout << endl; } return (num); } int main () { // variables int num1, num2, num; int smaller; int larger; int result; string str1 = "Enter the first number to be multiplied. "; string str2 = "Enter the second number to be multiplied. "; string odd = "add"; cout << "This program will multiply two numbers. " << endl << endl; num1 = numbers ( str1 ); // 1st call num2 = numbers ( str2 ); // 2nd call if ( num1 > num2 ) { larger = num1; smaller = num2; } else { larger = num2; smaller = num1; } for (larger; larger >= 1; larger /= 2 ) { if (smaller != larger) smaller *= 2; if ( larger % 2 > 0 ) odd = "add"; cout << larger << " " << smaller << " " << odd << endl; } cout << endl; result = num1 * num2; cout << num1 << " x " << num2 << " = " << result; cout << endl << endl; system ("pause"); return 0; }
This post has been edited by cball1321: 30 November 2008 - 09:05 PM