User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 332,561 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 2,076 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.
Please support our C++ advertiser:
Views: 162 | Replies: 5
Reply
Join Date: Apr 2008
Posts: 5
Reputation: latour1972 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
latour1972 latour1972 is offline Offline
Newbie Poster

How to start for this?

  #1  
7 Days Ago
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 2,642
Reputation: Salem is a splendid one to behold Salem is a splendid one to behold Salem is a splendid one to behold Salem is a splendid one to behold Salem is a splendid one to behold Salem is a splendid one to behold Salem is a splendid one to behold 
Rep Power: 16
Solved Threads: 275
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: How to start for this?

  #2  
7 Days Ago
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.
Reply With Quote  
Join Date: Dec 2007
Posts: 124
Reputation: henpecked1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
henpecked1 henpecked1 is offline Offline
Junior Poster

Re: How to start for this?

  #3  
7 Days Ago
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.
Reply With Quote  
Join Date: Apr 2008
Posts: 5
Reputation: latour1972 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
latour1972 latour1972 is offline Offline
Newbie Poster

Re: How to start for this?

  #4  
4 Days Ago
I know quotient and remainder mean but I still cant figure that out.....
Reply With Quote  
Join Date: Apr 2008
Posts: 56
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
tesuji tesuji is offline Offline
Junior Poster in Training

Re: How to start for this?

  #5  
4 Days Ago
Hi latour1972,

maybe these will help you:
  1. // Two function to computing quotient and remainder
  2. int quotient (int z ) { return z / 10; }
  3. int reminder ( int z ) { return z % 10; }
  4.  
  5. // Simple solution to split int number into its digits
  6. void demon ()
  7. { int n, d0, d1, d2, d3, d4;
  8. cout << "Enter an integer between 1 and 32767: ";
  9. cin >> n;
  10. cout << n << endl;
  11. d4 = reminder(n); n = quotient(n);
  12. d3 = reminder(n); n = quotient(n);
  13. d2 = reminder(n); n = quotient(n);
  14. d1 = reminder(n); d0= quotient(n);
  15. cout << d0 << " " << d1 << " " << d2 << " " << d3 << " " << d4 << endl;
  16. }
  17.  
  18.  
  19. // Below solution works recursively. Do you understand this?
  20. // if you call split (4562), result is 4 5 6 2
  21. void split(int n){
  22. int d = n % 10; n = n / 10;
  23. if ( n > 0) split (n);
  24. cout << d << " ";
  25. }
krs,
tesu
Reply With Quote  
Join Date: Apr 2008
Posts: 5
Reputation: latour1972 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
latour1972 latour1972 is offline Offline
Newbie Poster

Re: How to start for this?

  #6  
3 Days Ago
tks.....
I am working on this.....and it helps me to understand....



Originally Posted by tesuji View Post
Hi latour1972,

maybe these will help you:
  1. // Two function to computing quotient and remainder
  2. int quotient (int z ) { return z / 10; }
  3. int reminder ( int z ) { return z % 10; }
  4.  
  5. // Simple solution to split int number into its digits
  6. void demon ()
  7. { int n, d0, d1, d2, d3, d4;
  8. cout << "Enter an integer between 1 and 32767: ";
  9. cin >> n;
  10. cout << n << endl;
  11. d4 = reminder(n); n = quotient(n);
  12. d3 = reminder(n); n = quotient(n);
  13. d2 = reminder(n); n = quotient(n);
  14. d1 = reminder(n); d0= quotient(n);
  15. cout << d0 << " " << d1 << " " << d2 << " " << d3 << " " << d4 << endl;
  16. }
  17.  
  18.  
  19. // Below solution works recursively. Do you understand this?
  20. // if you call split (4562), result is 4 5 6 2
  21. void split(int n){
  22. int d = n % 10; n = n / 10;
  23. if ( n > 0) split (n);
  24. cout << d << " ";
  25. }
krs,
tesu
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:40 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC