Im really lost because there is a b in the code and also a *b in the code.... Also, b is declared in the very beginning as 11 and then it is redefined...
IS there any way someone can tell me why the first line of output is what it is ( basically explain the logic in one example)
Code:
#include <stdio.h>
int f(int *a, int *b); //this declares and integer a and b in function f. Correct? the '*' next to the variable represents that it is a pointer, right? where exactly is it pointing to?
int main() {
int a=9, b=11;
if (f(&b,&a))
printf("a = %d,b = %d\n",a,b);
else
printf("Zero is the answer.\n"); //so under what conditions is this going to print out?
b = f(&a, &b);
printf("a = %d,b = %d\n",a,b);
return 0; //what is the significance of having a return type?
}
int f(int* a, int* b) {
int c; //why does this program print out more than once? there isnt a loop anywhere...
c = 2*(*a)%(*b);
(*a) = c + (3*(*b)%(*a));
(*b) = c - (2*(*b)%(*a));
printf("a = %d,b = %d\n",*a,*b);
return c; // why does this say return c?
}