Answer the question
In order to leave comments, you need to log in
Si. How to make a function that multiplies a number?
How to make a function that, for example, when it is called
...
func(a);
...
divided the number a by 10 and stored it in the variable a
?
Answer the question
In order to leave comments, you need to log in
void func(int* a)
{
(*a)/=10;
}
int main()
{
int test=20;
func(&test);
printf("%d\n",test);
return 0;
}
Pass a by reference or pointer and do whatever you want inside it.
Of course, you were offered with a pointer, but you have to do it without a pointer.
int func(int x)
{
return x / 10;
}
...
a = func(a);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question