Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

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 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: ( ++, –)

Code based on the Arithmetic Operator

#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);

}