
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Simple Arithmetic Operators Example Program In C++
C++ has 5 basic arithmetic operators. They are −
- Addition(+)
- Subtraction(-)
- Division(/)
- Multiplication(*)
- Modulo(%)
These operators can operate on any arithmetic operations in C++. Let's have a look at an example −
Example
#include <iostream> using namespace std; main() { int a = 21; int b = 10; int c ; c = a + b; cout << "Line 1 - Value of c is :" << c << endl ; c = a - b; cout << "Line 2 - Value of c is :" << c << endl ; c = a * b; cout << "Line 3 - Value of c is :" << c << endl ; c = a / b; cout << "Line 4 - Value of c is :" << c << endl ; c = a % b; cout << "Line 5 - Value of c is :" << c << endl ; return 0; }
Output
This will give the output −
Line 1 - Value of c is :31 Line 2 - Value of c is :11 Line 3 - Value of c is :210 Line 4 - Value of c is :2 Line 5 - Value of c is :1
- Related Articles
- Arithmetic Operators in C++
- Python Arithmetic Operators
- Java arithmetic operators
- Perl Arithmetic Operators
- Arithmetic operators in Dart Programming
- What are Arithmetic Operators in JavaScript?
- What are arithmetic operators in C#?
- What are the arithmetic operators in Java?
- What are different arithmetic operators in Python?
- How to sum two integers without using arithmetic operators in C/C++ Program?
- What is operand of arithmetic operators in Java
- Why in MySQL, we cannot use arithmetic operators like ‘=’, ‘
- Explain the concept of Arithmetic operators in C language
- What are the arithmetic and character operators in DBMS?
- How to do simple Arithmetic on Linux Terminal?

Advertisements