I'm trying to learn C++ at my own pace via an online course. There is a function declaration and also there is an integer declaration just after that, which is q.
I don't understand what purpose the "q" serves in the code.
I tried to print out each step and it didn't make sense. I literally don't see the point of having a "q" in the foo function or what it does.
#include<stdio.h>
int foo (int q) {
int x = 1;
return (q + x);
}
int main (){
int x = 0;
while (x < 3) {
printf ("%i\n", x);
x = x + foo(x);
}
}
This code gives me 0 1 Seems like the "q" is incrementing x but I don't see the reason why because we didn't assign it to anything but just saying (int q)