P
P
prohoroffff2016-01-16 20:27:10
C++ / C#
prohoroffff, 2016-01-16 20:27:10

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

4 answer(s)
A
Armenian Radio, 2016-01-16
@prohoroffff

void func(int* a)
{
   (*a)/=10;
}

call
int main()
{
    int test=20;
    func(&test);
    printf("%d\n",test);
    return 0;
}

D
Dmitry Kovalsky, 2016-01-16
@dmitryKovalskiy

Pass a by reference or pointer and do whatever you want inside it.

A
abcd0x00, 2016-01-17
@abcd0x00

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);

R
romy4, 2016-01-16
@romy4

use a reference or a pointer as a parameter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question