# simple program giving me issues:

• 07-13-2013
jocdrew21
simple program giving me issues:
All I want to do is divide the smaller number into the larger one. I has no issues test and getting the right answer. Now I wanted to pass the remainder and this is where the issues came.

After I can effectively get the remainder passed to (int sum2) I want to divide the smaller remainder into the larger one until the remainder is 0. I'll use a "while" statement for this.

Right now if I divide 9 / 3 = 0 r 3
3 / 9 = 0 r 3

5 / 5 = 32767 R 1606416048

This is a very simple program and I going in circles here. Can anyone help.

Code:

``` int remainder (int, int);          // function protoype // #include <stdio.h> int remainder(int x, int y)        // function header // {     int sum1, sum2;         if (x > y) {                    // the lesser divided into the highier //         sum1 = y / x;         sum2 = y%x;                // the remainder is passed to sum2 //     }     if (y > x) {         sum1 = x / y;         sum2 = x%y;     }       return printf("The answer is %d and the remainder is %d", sum1, sum2);         } int main(int argc, const char * argv[]) {     int x,y;         printf("Enter two numbers\n");     scanf("%d%d",&x, &y);         remainder(x, y);        // function called //         return 0; } ```
• 07-13-2013
vart
Well - what do you think your program should print when y==x?
• 07-13-2013
Barney McGrew
Three issues.

If x == y, sum1 and sum2 will be referenced without having a value stored in them, which seems to be the problem you're most concerned with. I'm sure you can fix that.

const char ** isn't compatible with char **, so your definition for main may not be allowed by your C implementation.

If scanf returns a value that isn't 2, x or y will be referenced without having a value stored in them.

EDIT: Also, you don't print a terminating new line to stdout.