Arithmetic Operators in C ++

 Arithmetic Operators in C++

Arithmetic operators are used to perform mathematical calculations on numerical values (operands) in C++. These operators include:

 * Addition (+): Adds two operands.

   int a = 5, b = 3;

int sum = a + b; // sum will be 8


 * Subtraction (-): Subtracts the second operand from the first.

   int a = 10, b = 4;

int difference = a - b; // difference will be 6


 * Multiplication (*): Multiplies two operands.

   int a = 2, b = 6;

int product = a * b; // product will be 12


 * Division (/): Divides the first operand by the second.

   int a = 15, b = 3;

int quotient = a / b; // quotient will be 5


 * Modulus (%): Returns the remainder of the division between two operands.

   int a = 7, b = 3;

int remainder = a % b; // remainder will be 1


 * Increment (++): Increases the value of an operand by 1.

   int a = 5;

a++; // a will be 6


 * Decrement (--): Decreases the value of an operand by 1.

   int a = 5;

a--; // a will be 4


Operator Precedence

When multiple operators are used in an expression, the order of evaluation is determined by operator precedence. The order is as follows:

 * Parentheses ()

 * Increment/decrement ++, -- (prefix)

 * Multiplication/division/modulus *, /, %

 * Addition/subtraction +, -

 * Increment/decrement ++, -- (postfix)

Example:

int result = 2 + 3 * 4; // result will be 14 (multiplication has higher precedence)


By understanding arithmetic operators and their precedence, you can effectively perform calculations and manipulate numerical values in your C++ programs.


Comments

🎮 POPÜLER ⭐ 4.5

Ultra Blocks

Klasik Bulmaca · Strateji · Zeka Oyunu

Hızlı düşün, akıllıca istifle ve küresel liderlik tablosunda zirveye oyna! Ultra Blocks, klasik arcade bulmaca mantığını modern strateji ve göz alıcı görsel efektlerle birleştiriyor. Blokları sürükleyip yerleştir, tam satırları temizle ve rekorlarını kır!

🏆 Küresel Sıralama PlayFab ile dünyaya meydan oku
🎨 Özelleştirilebilir Tema Neon’dan klasik ahşaba
📱 Her Cihazda Telefon, tablet, TV ve katlanabilir
👑 VIP Kulüp Reklamsız · Sınırsız döndürme
⬇️ Google Play'den Ücretsiz İndir
📦 50 MB · Çevrimdışı oynanabilir 🔒 Veriler şifrelenir

Popular posts from this blog

Kotlin Hello World

Kotlin Android Program (QCR) Application Codes That Read Text in Photos

Kotlin Google Sign in Activity with Layout Example