Arithmetic operators in C

Operator in C

Operator is a symbol which are used to perform logical and mathematical manipulation in a C program are called C operators.

These operator are used manipulate for  data and variable.

Operators, functions, constants and variables are combined together to form expressions.

eg:  x+y *5, where +,* is the operator and x,y is variable and 5 is constant last x+y*5 is the expression.

Arithmetic Operator in C

Arithmetic Operator or mathematical Operator is used for the calculation.

These are the symbol  is to perform mathematically operation. eg: (+, -, *, /, %, ++)

There are two types of Arithmetic operator.

1)Binary Operator

A binary operator is an operator that operates on two operands and manipulates them to return a result.

eg; (+,  -,  *,  / )

2)Unary Operator

A unary operator ,is an operator that takes a single operand in an expression or a statement.

eg: ( ++, –)

Arithmetic operators in C

Code based on the Arithmetic Operator

Run
#include <stdio.h>

int main()
{
 int a = 9, b = 10;
 int addition, subtraction, multiplication, division, modulus;
 
 addition = a + b; //addition of 9 and 10
 subtraction = a - b; //subtract 9 from 10
 multiplication = a * b; //Multiplying both 9 and 10
 division = a / b; //dividing 10 by 9 (number of times)
 modulus = a % b; //calculation the remainder
 
 printf("Addition of two numbers a, b is : %d\n", addition);
 printf("Subtraction of two numbers a, b is : %d\n", subtraction);
 printf("Multiplication of two numbers a, b is : %d\n", multiplication);
 printf("Division of two numbers a, b is : %d\n", division);
 printf("Modulus of two numbers a, b is : %d\n", modulus);
}

Output

Addition of two numbers a, b is : 19
Subtraction of two numbers a, b is : -1
Multiplication of two numbers a, b is : 90
Division of two numbers a, b is : 0
Modulus of two numbers a, b is : 9 

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription