469,336 Members | 5,980 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Write a statement that declares a prototype for a function divide

64
Here is the question....Write a statement that declares a prototype for a function divide that takes four arguments and returns no value. The first two arguments are of type int . The last two arguments arguments are pointers to int that are set by the function to the quotient and remainder of dividing the first argument by the second argument. The function does not return a value.

Here is my code

Expand|Select|Wrap|Line Numbers
  1. void divide(int , int, pInt* quotient, pInt* remainder);
But it doesn't work! What am I doing wrong? Thanks in advance guys!
Feb 14 '07 #1
5 8028
sicarie
4,677 Expert Mod 4TB
Here is the question....Write a statement that declares a prototype for a function divide that takes four arguments and returns no value. The first two arguments are of type int . The last two arguments arguments are pointers to int that are set by the function to the quotient and remainder of dividing the first argument by the second argument. The function does not return a value.

Here is my code

Expand|Select|Wrap|Line Numbers
  1. void divide(int , int, pInt* quotient, pInt* remainder);
But it doesn't work! What am I doing wrong? Thanks in advance guys!
Off the top of my head I'd say that looks right (you might consider trying to put variable names in the int places, or taking them out of the quotient/remainder, but that also looks like a function declaration, in which case I didn't think it mattered...), can you post the entire code you are using?
Feb 14 '07 #2
td0g03
64
Off the top of my head I'd say that looks right (you might consider trying to put variable names in the int places, or taking them out of the quotient/remainder, but that also looks like a function declaration, in which case I didn't think it mattered...), can you post the entire code you are using?
Well, its a website where I input information/codes and it tells me if it a correct. So I don't have the whole code just the question. Sorry.
Feb 14 '07 #3
td0g03
64
Well, its a website where I input information/codes and it tells me if it a correct. So I don't have the whole code just the question. Sorry.
Ah, I got it to work. It ended up being void divide(int a, int a, int* quotient,int* remainder);
Feb 14 '07 #4
Ganon11
3,652 Expert 2GB
I had my doubts about pInt* - I don't think that's even a supported type. int* would have been correct.

Glad to see you got it!
Feb 14 '07 #5
sicarie
4,677 Expert Mod 4TB
And just so you are aware - void divide(int a, int a, int* quotient,int* remainder); uses the same variable name in two different places. When you try to access one of the ints, you will not be able to get the value inside the function - you will only get one, I'd recommend changing it to either a descriptive name or 'b' or something.
Feb 14 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by James Marshall | last post: by
8 posts views Thread by Ben | last post: by
13 posts views Thread by Roy Hills | last post: by
35 posts views Thread by Thierry Loiseau | last post: by
13 posts views Thread by eman1000 | last post: by
4 posts views Thread by Vince Castellano | last post: by
3 posts views Thread by June Lee | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.