This program reads twe intgers and then prints the
Quotient and Remainder of the first number divided by second
SoUrCe CoDe:
OuTpUt:
Quotient and Remainder of the first number divided by second
SoUrCe CoDe:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #include <iostream.h> #include <conio.h> #include <iomanip.h> using namespace std; // Prototype Declarations void getData (int& divnd, int& divsr); void divide (int divnd, int divsr, int& quot, int& rem); void print (int quot, int rem); int main() { int a; int b; getData (a, b); int c; int d; divide (a, b, c, d); print (c, d); getch(); return 0; } // main /* ============= getData ====================== This function reads two numbers into variables specified in the parameter list. Pre nothing Post Data read and placed in calling function */ void getData (int& divnd, int& divsr) { cout << " Enter two Intger and Return: "; cin >> divnd >> divsr; return; } //getData /* =================== divide ================== This function divides two intger and the reminder. Quotient / reminder in calling program variable Pre dividend & divisor contain integer value Post quotient & reminder calc'd */ void divide (int divnd, int divsr, int& quot, int& rem ) { quot = divnd / divsr; rem = divnd % divsr; getch(); return; } // divide /* =================== Print ================== This function prints the quotient and reminder. Pre quot contions the quotient rem contains the reminder Post quotient and reminder printed */ void print (int quot, int rem) { cout << " Quotient : "; cout << setw(4) << quot << endl; cout << " Reminder : "; cout << setw(4) << rem << endl; return ; } // print |
OuTpUt:
Enter two Intger and Return: 5678 2134 Quotient : 2 Reminder : 1410
No comments:
Post a Comment