Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Simple Math | Variables
Introduction to C++ | Mobile-Friendly

bookSimple Math

To perform arithmetic operations on variables and values C++ supports the following arithmetic operators:

Let’s try:

int sum = 10 + 3; // 13
int dif = 10 - 3; // 7
int mul = 10 * 3; // 30
int div = 10 / 3; // 3
int mod = 10 % 3; // 1

By division, any remainder was dropped since we assign the result to the int variable which doesn’t contain any decimals.

You can use all operations above to perform calculations on values, variables, or between variable and value:

double a = 32.1 + 13.2;    // 45.3 
double b = a + 25.3;       // 45.3 + 25.3 = 70.6
double c = a + b;          // 70.6 + 45.3 = 115.9
question mark

The velocity of the car is 27 miles per hour. After 3 hours, how many miles will it drive? Choose the line which solves this excersice.

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 5

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Spørg mig spørgsmål om dette emne

Opsummér dette kapitel

Vis virkelige eksempler

Awesome!

Completion rate improved to 3.7

bookSimple Math

Stryg for at vise menuen

To perform arithmetic operations on variables and values C++ supports the following arithmetic operators:

Let’s try:

int sum = 10 + 3; // 13
int dif = 10 - 3; // 7
int mul = 10 * 3; // 30
int div = 10 / 3; // 3
int mod = 10 % 3; // 1

By division, any remainder was dropped since we assign the result to the int variable which doesn’t contain any decimals.

You can use all operations above to perform calculations on values, variables, or between variable and value:

double a = 32.1 + 13.2;    // 45.3 
double b = a + 25.3;       // 45.3 + 25.3 = 70.6
double c = a + b;          // 70.6 + 45.3 = 115.9
question mark

The velocity of the car is 27 miles per hour. After 3 hours, how many miles will it drive? Choose the line which solves this excersice.

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 5
some-alt