1. ## C-another Pointer program.

Code:
```#include <stdio.h>

int f(int c, int b, int a);

int main() {
int a=2, b=3, c=5;
printf("a=%d b=%d c=%d\n",a,b,c);

a = f(b, a, b+c);
printf("a=%d b=%d c=%d\n",a,b,c);

system("pause");
return 0;
}

int f(int c, int b, int a) {
int sum;
sum = a + b + c;
if(sum > a*c)
return a*c;
if(sum <= b*c)
return b*c;

return a*b;
}```
Output:
a=2 b=3 c=5
a=16 b=3 c=5

I am starting to understand pointer but still confused.
Does sum equal to 13? If so, what is a,b,c and where to obtain the variables for a,b,c: a+b+c=13?
Code:
```    if(sum > a*c)        return a*c;
if(sum <= b*c)
return b*c;

return a*b;```
Why are there two returns assuming one of the "if" statement is true?

Lastly, what does
Code:
`    a = f(b, a, b+c);`
implies?

Thank You.

2. Originally Posted by 5360
I am starting to understand pointer but still confused.
I note that you do not directly use any pointers in your program.

Originally Posted by 5360
Does sum equal to 13?
Use a debugger to find out. If one is not available to you, then print the value of sum at the point where you want to know what it is equal to.

Originally Posted by 5360
If so, what is a,b,c and where to obtain the variables for a,b,c: a+b+c=13?
It looks like your assignment is designed for confusion. I suggest that you consider this program, which is exactly the same as the program you posted except for variable names:
Code:
```#include <stdio.h>

int f(int x, int y, int z);

int main() {
int a=2, b=3, c=5;
printf("a=%d b=%d c=%d\n",a,b,c);

a = f(b, a, b+c);
printf("a=%d b=%d c=%d\n",a,b,c);

system("pause");
return 0;
}

int f(int x, int y, int z) {
int sum;
sum = z + y + x;
if(sum > z * x)
return z*x;
if(sum <= y * x)
return y * x;

return z * y;
}```
Originally Posted by 5360
Why are there two returns assuming one of the "if" statement is true?
The first of the two for which the if statement's condition evaluates to true will be used.

Originally Posted by 5360
Lastly, what does
Code:
`a = f(b, a, b+c);`
implies?
That is just a function call.

3. Ok using int x, y z clears up some of my questions and sum does equal to 13.

One last question, how do I find the variables for x,y, and z that will equal to sum?

4. Originally Posted by 5360
One last question, how do I find the variables for x,y, and z that will equal to sum?
What do you mean?

5. Originally Posted by laserlight
What do you mean?
what is the value of x? or another way to ask: how do I find the value of x?
what is the value of y?
what is the value of z?

I just cannot get my head wrap around it...

6. Consider a simpler example:
Code:
```#include <stdio.h>

void print_number(int n)
{
printf("%d\n");
}

int main(void)
{
print_number(10 + 20);
return 0;
}```
So, the value of the formal parameter n is the value of the actual argument passed when calling print_number, i.e., 10 + 20, hence the value of n is 30.

7. Originally Posted by laserlight
Consider a simpler example:
Code:
```#include <stdio.h>

void print_number(int n)
{
printf("%d\n");
}

int main(void)
{
print_number(10 + 20);
return 0;
}```
So, the value of the formal parameter n is the value of the actual argument passed when calling print_number, i.e., 10 + 20, hence the value of n is 30.
I finally see it, thank you very much!!!