| | |
Urgent help #3
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 22
Reputation:
Solved Threads: 0
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
_____
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
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.
•
•
Join Date: Oct 2009
Posts: 27
Reputation:
Solved Threads: 2
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...
C++ Syntax (Toggle Plain Text)
#include <stdio.h> #include <math.h> #include <iostream> #include <windows.h> using namespace std; int main(void) { int numerator=42, denominator=5, quotient, <strong class="highlight">remainder</strong>; divide(numerator,denominator,"ient,&<strong class="highlight">remainder</strong>); printf("numerator = %d\n", numerator); printf("denominator = %d\n", denominator); printf("quotient = %d\n", quotient); printf("<strong class="highlight">remainder</strong> = %d\n", <strong class="highlight">remainder</strong>); if (remainder > 0) { cout<<"Calculations did not come out to a whole number!\n"; } else cout<<"The remainder is 0, calculations = whole number return 0; } /* my output numerator = 42 denominator = 5 quotient = 8 <strong class="highlight">remainder</strong> = 5 */
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!
URL on facebook!
•
•
Join Date: Jan 2008
Posts: 3,844
Reputation:
Solved Threads: 503
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/
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/
•
•
Join Date: Oct 2009
Posts: 27
Reputation:
Solved Threads: 2
-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...
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
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <windows.h> #include <math.h> #include <cmath> using namespace std; int main() { int a,d,q,r; cout<<"Numerator: \n"; cin>> a; //a is divident (numerator) cout<<"Denominator: \n"; cin>> d; r= abs(a - (q * d)); // d is divisor (denominator) q=((a) / (d)); //q is quotient (plain old value without remainder) //r is remainder cout<< a <<" / "<< d <<" = "<< q <<" with remainder "<< r <<endl; Sleep(3000); return 0; }
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
•
•
Join Date: Jan 2008
Posts: 3,844
Reputation:
Solved Threads: 503
1
#7 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...
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <windows.h> #include <math.h> #include <cmath> using namespace std; int main() { int a,d,q,r; cout<<"Numerator: \n"; cin>> a; //a is divident (numerator) cout<<"Denominator: \n"; cin>> d; r= abs(a - (q * d)); // d is divisor (denominator) q=((a) / (d)); //q is quotient (plain old value without remainder) //r is remainder cout<< a <<" / "<< d <<" = "<< q <<" with remainder "<< r <<endl; Sleep(3000); return 0; }
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
![]() |
Similar Threads
- pls heeeeeeeeelp its urgent. (C)
- Urgent! (C++)
- URGENT: Need help on I/O code! (Java)
- Urgent help (Networking Hardware Configuration)
- Homepage keeps switching back to a porn site (Web Browsers)
- Importing SQL Script File - Urgent !! (Database Design)
Other Threads in the C++ Forum
- Previous Thread: Syntax error in "array and 2D array"
- Next Thread: Do/While Loop help
Views: 239 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines linker list loop looping loops map math matrix memory newbie news number output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






