help!!

i need to write a piece of code that will take a number stored in an array and divide it by another number stored in a different array, then output the answer into a new array.

but it should only read the number into the array if the two numbers divide exactly, i.e to give an integer.

thanks!!!!

2. Well, what do you have so far? Or did you want somebody to write the whole program for you? If this is for homework, that's not something this board is really for..

I would start by creating the arrays you need. If you only need one element in each array, I would just use int variables - but if your teacher is trying to get you to use arrays, then just declare an array with a single element:

Code:
`int myArray[1];`
As far as making sure they're integers, here's a function you can use:

Code:
`if (is_int(myNum)) { ... }`
Sorry, I don't know what library that is included in and I'm at work so I can't check for you - I'm sure somebody else knows this

3. any guidance as to how to do this would be a great help

5. As far as making sure they're integers
It sounds like the poster starts with integers, and has to check if the division would produce a whole number, which can be done using the HINT TO POSTER: modulus operator %

6. The poster needs to see if the division produces an integer. It sounds like the poster starts with integers, and has to check if the division produces an integer, which would require using the HINT TO POSTER: modulus operator %
Duh. Another hint: It's always best NOT to listen to me if it's before 9am LOL

7. this is part of a bigger program i need to write -

basically i am trying to verify (2^512)+1 has ceratin factors, but since its too large to store as an int, i have to store it in an array then run a for loop dividing (2^512)+1by every number from 0...(2^512)+1 and outputting only those numbers that are integers.

anyway .. if anyone can point me in the right direction that would be great, thanks

8. they have already given you the MAIN hint to do that. you need to use the % modulus operator. Every beginners book has sample programs on this operator, or you can visit the tutorials on the main page of this site.

edit: another hint, in your for loop use an if statement.

9. i dont think the percentage operator will help here,

imagine i have 176 stored in an array of size 3, each digit in each element
i then have another array of size 3 holding , 0,0,8, as in the number 8.

how do i do division on these and output the answer into a new array.

10. ....

11. % in C++ is the modulus operator - NOT percent. C++ does not have an operator to take the percentage.

Modulus performs division and returns the remainder. If there is no remainder, the division would result in an INT.

12. the % is called the modulus operator, not the percenatage operator. try this example and maybe you can understand btter what you need to do.

Code:
```#include <stdio.h>
main()
{
int i;
printf("Even numbers    Odd Numbers\n");
for (i =0; i<100; i++)
if (i%2==0)
printf("%d", i);
else
printf("%16d\n", i);
return 0;
}```
edit: sorry for posting C code on C++ forum. caution when you run this code.

13. i understand what the modulus operator does but the point is that each digit of the number is stored in an array -

so 176 is stored in an array of size 3 with each digit in each array element
then 8 is stored in an array of size 3 with zeros in the first two elements and 8 in the last.

If i want to divide 176 by 8 and return the result in another array - how do i do this - if it can be done at all????

14. oh well ...

15. Well gee...basic math.

Sum the first digit with the next digit*10, sum that with the next digit*100. 6 + 70 + 100 is equal to what? From there I think you should be able to figure it out.