return value in function
i want to display a number given by the user. the for loop in the function num should increase the number what is being added to the number given by the user. this happens ten times.
int main ()
int i, input, result;
printf("enter a number: ");
result = input + num();
printf("your number %d + %d gives %d\n", input, num(), result);
the output should look like this
your number 1 + 1 gives 2
your number 1 + 2 gives 3
your number 1 + 3 gives 4
i guess its a really simply mistake in the num function but i need help ;)
>i guess its a really simply mistake in the num function but i need help
Well, you could start by trying to print something within the loop. :)
At the moment your code (function num) simply loops i from 0 to 10) and returns 10. Then it prints out. See the mistake now?
the problem is you only call num () once or print the results once. think about the logical flow of your code: if you want to do it more than once, than your printf () call must be contained in a loop.
edit: arrrg hammer you're too fast!