Urgent help #3

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 22
Reputation: sebassn is an unknown quantity at this point 
Solved Threads: 0
sebassn sebassn is offline Offline
Newbie Poster

Urgent help #3

 
-4
  #1
Oct 9th, 2009
This is anothe exercise I got, but I haven't done anything just because I need how to get the code, as if I would write it in a piece of paper:

_____

Write the code that prompts the user to enter two integer numbers, numerator and denominator. Your program should determine(output) if the number is divisible by the denominator.

NOTE: your are not allowed to use % operator!.


THANKS
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 195
Reputation: necrolin will become famous soon enough necrolin will become famous soon enough 
Solved Threads: 20
necrolin's Avatar
necrolin necrolin is offline Offline
Junior Poster
 
1
  #2
Oct 9th, 2009
The way that you do this exercise is you bust out your handy dandy computer, use your problem solving skills to work it out yourself, try to compile the program, and if you still have problems you ask on a forum. You've just posted 3 of your homework assignments with absolutely no code and no effort put into doing them yourself. Common what are you trying to do? It's your homework not ours.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 27
Reputation: triumphost is an unknown quantity at this point 
Solved Threads: 2
triumphost triumphost is offline Offline
Light Poster
 
0
  #3
Oct 9th, 2009
Doesnt exactly compile for me for whatever reason but im guess thats how you go about it... found it on this forum... And yes you should search how to do stuff rather than getting spoon fed cuz no one will just write code without you putting in effort... im only helping you start off... if the following compiles for you then ur good other than that edit and do whatever you want...



  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <iostream>
  4. #include <windows.h>
  5.  
  6. using namespace std;
  7.  
  8. int main(void)
  9. {
  10. int numerator=42, denominator=5, quotient, <strong class="highlight">remainder</strong>;
  11. divide(numerator,denominator,&quotient,&<strong class="highlight">remainder</strong>);
  12. printf("numerator = %d\n", numerator);
  13. printf("denominator = %d\n", denominator);
  14. printf("quotient = %d\n", quotient);
  15. printf("<strong class="highlight">remainder</strong> = %d\n", <strong class="highlight">remainder</strong>);
  16.  
  17. if (remainder > 0)
  18. {
  19. cout<<"Calculations did not come out to a whole number!\n";
  20. }
  21. else
  22. cout<<"The remainder is 0, calculations = whole number
  23.  
  24. return 0;
  25. }
  26.  
  27. /* my output
  28. numerator = 42
  29. denominator = 5
  30. quotient = 8
  31. <strong class="highlight">remainder</strong> = 5
  32. */
  33.  
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 468
Reputation: Grn Xtrm will become famous soon enough Grn Xtrm will become famous soon enough 
Solved Threads: 39
Grn Xtrm's Avatar
Grn Xtrm Grn Xtrm is offline Offline
Posting Pro in Training
 
1
  #4
Oct 9th, 2009
LOL. This code is half C and half C++. Maybe call it "C squared ++"
Check out my new band URL on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
URL on facebook!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,844
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #5
Oct 9th, 2009
I don't know what you're doing with the posts, but preview them before you post. You have some odd tags. Perhaps you pasted html code rather than plain text code and pasted it here. Hit "Preview Post" to make sure things look right, then fix the post if there's something wrong.

Is there some "divide" function you didn't post? If not, there's your error.

Here are the libraries you can use. If your function isn't in one of them, you have to write it yourself.

http://www.cplusplus.com/reference/
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 27
Reputation: triumphost is an unknown quantity at this point 
Solved Threads: 2
triumphost triumphost is offline Offline
Light Poster
 
-2
  #6
Oct 10th, 2009
Ok well I got your PM but the thing is if you cant use the modulo sign (%) then you may be able to use this... you better be greatful cuz this is a formula i had to work out myself on pencil paper...

  1. #include <iostream>
  2. #include <windows.h>
  3. #include <math.h>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int a,d,q,r;
  11. cout<<"Numerator: \n";
  12. cin>> a; //a is divident (numerator)
  13. cout<<"Denominator: \n";
  14. cin>> d;
  15.  
  16. r= abs(a - (q * d)); // d is divisor (denominator)
  17. q=((a) / (d)); //q is quotient (plain old value without remainder)
  18.  
  19. //r is remainder
  20.  
  21. cout<< a <<" / "<< d <<" = "<< q <<" with remainder "<< r <<endl;
  22.  
  23. Sleep(3000);
  24. return 0;
  25. }


RELEASE NOTE: there is a bug in my code for some reason... when I ask it to output remainder, it outputs a huge!!! number which is impossible looking at the code... pick numerator 10, denominator 2, and itll still give u remainder of like 2300000 or something stupid like that so if u fix that then ur good or maybe its just my computer
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,844
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
1
  #7
Oct 10th, 2009
Originally Posted by triumphost View Post
Ok well I got your PM but the thing is if you cant use the modulo sign (%) then you may be able to use this... you better be greatful cuz this is a formula i had to work out myself on pencil paper...

  1. #include <iostream>
  2. #include <windows.h>
  3. #include <math.h>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int a,d,q,r;
  11. cout<<"Numerator: \n";
  12. cin>> a; //a is divident (numerator)
  13. cout<<"Denominator: \n";
  14. cin>> d;
  15.  
  16. r= abs(a - (q * d)); // d is divisor (denominator)
  17. q=((a) / (d)); //q is quotient (plain old value without remainder)
  18.  
  19. //r is remainder
  20.  
  21. cout<< a <<" / "<< d <<" = "<< q <<" with remainder "<< r <<endl;
  22.  
  23. Sleep(3000);
  24. return 0;
  25. }


RELEASE NOTE: there is a bug in my code for some reason... when I ask it to output remainder, it outputs a huge!!! number which is impossible looking at the code... pick numerator 10, denominator 2, and itll still give u remainder of like 2300000 or something stupid like that so if u fix that then ur good or maybe its just my computer

It's not your computer. It's your code. I'd explain what is wrong with it, but that might mean sebassn could put absolutely no effort into this and get the complete answer. sebassn, three verbatim homework posts with absolutely no effort. AND you're asking for help via PM, which is a big no-no on this forum. Read the rules, all of them. Here's the main one.

http://www.daniweb.com/forums/announcement8-2.html
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C++ Forum


Views: 239 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC