Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære More about Parameters | Functions
C++ Intermediate | Mobile-Friendly
course content

Kursinnhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

1. Data Types and Arrays
2. References & Pointers
3. Dynamic Memory
4. Functions

book
More about Parameters

Multiple parameters can also be used if you want to make math calculations or describe some logic. For example, we want to write the function which will write the average of 2 numbers (sum of numbers divided by its count):

1234567891011
// Declaration of the function, which calculates the mean of 2 numbers void avr(int a, int b) { &nbsp;&nbsp;&nbsp;&nbsp;cout << (a+b)/2 << endl; } int main() { &nbsp;&nbsp;&nbsp;&nbsp;// Call the function to be executed &nbsp;&nbsp;&nbsp;&nbsp;avr(4, 8); &nbsp;&nbsp;&nbsp;&nbsp;avr(3, 5); &nbsp;&nbsp;&nbsp;&nbsp;return 0; }
copy

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 4

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

1. Data Types and Arrays
2. References & Pointers
3. Dynamic Memory
4. Functions

book
More about Parameters

Multiple parameters can also be used if you want to make math calculations or describe some logic. For example, we want to write the function which will write the average of 2 numbers (sum of numbers divided by its count):

1234567891011
// Declaration of the function, which calculates the mean of 2 numbers void avr(int a, int b) { &nbsp;&nbsp;&nbsp;&nbsp;cout << (a+b)/2 << endl; } int main() { &nbsp;&nbsp;&nbsp;&nbsp;// Call the function to be executed &nbsp;&nbsp;&nbsp;&nbsp;avr(4, 8); &nbsp;&nbsp;&nbsp;&nbsp;avr(3, 5); &nbsp;&nbsp;&nbsp;&nbsp;return 0; }
copy

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 4
Vi beklager at noe gikk galt. Hva skjedde?
some-alt