•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,600 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,752 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 326 | Replies: 5
![]() |
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Write two program segments (functions) that accomplish each of the following:
a) A function that Calculates the integer part of the quotient when integer a is divided by integer b.
b) A function that Calculates the integer remainder when integer a is divided by integer b.
Use the functions developed in (a) and (b) to write a function that inputs an integer between 1 and 32767 and prints it as a series of digits, each pair of which is separated by two spaces. For example, the integer 4562 should print as follows: 4 5 6 2
a) A function that Calculates the integer part of the quotient when integer a is divided by integer b.
b) A function that Calculates the integer remainder when integer a is divided by integer b.
Use the functions developed in (a) and (b) to write a function that inputs an integer between 1 and 32767 and prints it as a series of digits, each pair of which is separated by two spaces. For example, the integer 4562 should print as follows: 4 5 6 2
Do you know what quotient and remainder mean?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
•
•
Join Date: Dec 2007
Posts: 218
Reputation:
Rep Power: 1
Solved Threads: 1
they've actually given you the psuedocode for it, if it helps to get you started, just pick two numbers and do the math operation on paper and that will help you write your functions...make sure you use the correct operators indicated by the results the psuedocode asks for. Your instructor should have shown you how to do spaces in a cout statement for your spacing problem.
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
Hi latour1972,
maybe these will help you:
krs,
tesu
maybe these will help you:
cpp Syntax (Toggle Plain Text)
// Two function to computing quotient and remainder int quotient (int z ) { return z / 10; } int reminder ( int z ) { return z % 10; } // Simple solution to split int number into its digits void demon () { int n, d0, d1, d2, d3, d4; cout << "Enter an integer between 1 and 32767: "; cin >> n; cout << n << endl; d4 = reminder(n); n = quotient(n); d3 = reminder(n); n = quotient(n); d2 = reminder(n); n = quotient(n); d1 = reminder(n); d0= quotient(n); cout << d0 << " " << d1 << " " << d2 << " " << d3 << " " << d4 << endl; } // Below solution works recursively. Do you understand this? // if you call split (4562), result is 4 5 6 2 void split(int n){ int d = n % 10; n = n / 10; if ( n > 0) split (n); cout << d << " "; }
tesu
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
tks.....
I am working on this.....and it helps me to understand....
I am working on this.....and it helps me to understand....
•
•
•
•
Hi latour1972,
maybe these will help you:
krs,cpp Syntax (Toggle Plain Text)
// Two function to computing quotient and remainder int quotient (int z ) { return z / 10; } int reminder ( int z ) { return z % 10; } // Simple solution to split int number into its digits void demon () { int n, d0, d1, d2, d3, d4; cout << "Enter an integer between 1 and 32767: "; cin >> n; cout << n << endl; d4 = reminder(n); n = quotient(n); d3 = reminder(n); n = quotient(n); d2 = reminder(n); n = quotient(n); d1 = reminder(n); d0= quotient(n); cout << d0 << " " << d1 << " " << d2 << " " << d3 << " " << d4 << endl; } // Below solution works recursively. Do you understand this? // if you call split (4562), result is 4 5 6 2 void split(int n){ int d = n % 10; n = n / 10; if ( n > 0) split (n); cout << d << " "; }
tesu
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- How can i get Quick Launch on start Bar in Windows-NT(workstation) (Windows NT / 2000 / XP / 2003)
- As a newbie, where i should start from in linux? (Getting Started and Choosing a Distro)
- where to start with perl? (Perl)
- Start up Menu problems (Windows NT / 2000 / XP / 2003)
- mysql start up problem (MySQL)
- IE 6 start page getting changed to about:blank (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: Need advice on shortest path algorithms
- Next Thread: Number Conversions



Linear Mode