Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Arithmetic operators in C are used to perform mathematical operations on operands. Here’s an explanation of each arithmetic operator with a definition, example, and output:

1. Addition +:

Definition:

Adds two operands.

Example:

#include <stdio.h>

int main() {
int sum = 5 + 3;
printf(“Sum: %dn”, sum);
return 0;
}

Output:

Sum: 8

2. Subtraction -:

Definition:

Subtracts the right operand from the left operand.

 

Example:

#include <stdio.h>

int main() {
int difference = 5 – 3;
printf(“Difference: %dn”, difference);
return 0;
}

Output:

Difference: 2

3. Multiplication *:

Definition:

Multiplies two operands.

Example:

#include <stdio.h>

int main() {
int product = 5 * 3;
printf(“Product: %dn”, product);
return 0;
}

Output:

Product: 15

4. Division /:

Definition:

Divides the left operand by the right operand.

Example:

#include <stdio.h>

int main() {
int quotient = 10 / 3;
printf(“Quotient: %dn”, quotient);
return 0;
}

Output:

Quotient: 3

5. Modulus %:

Definition:

Returns the remainder of the division of the left operand by the right operand.

Example:

#include <stdio.h>

int main() {
int remainder = 10 % 3;
printf(“Remainder: %dn”, remainder);
return 0;
}

Output:

Remainder: 1

6. Increment ++:

Definition:

Increases the value of the operand by 1.

Example:

#include <stdio.h>

int main() {
int a = 5;
int b = ++a;
printf(“Increment: %dn”, b);
return 0;
}

Output:

Increment: 6

7. Decrement –:

Definition:

Decreases the value of the operand by 1.

Example:

#include <stdio.h>

int main() {
int a = 5;
int b = –a;
printf(“Decrement: %dn”, b);
return 0;
}

Output:

Decrement: 4

 

These arithmetic operators are fundamental for performing mathematical calculations in C programs. Understanding how they work is essential for writing efficient and accurate code.