
- 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
Character arithmetic in C
Character arithmetic is used to implement arithmetic operations like addition and subtraction on characters in C language. It is used to manipulate the strings. When the characters are used with the arithmetic operations, it converts them into integer value automatically i.e. ASCII value of characters.
Here is an example of character arithmetic in C language,
Example
#include <stdio.h> int main(){ char s = 'm'; char t = 'z' - 'y'; printf("%d\n", s); printf("%c\n", s); printf("%d\n", (s+1)); printf("%c\n", (s+1)); printf("%d\n", (s-1)); printf("%c\n", (s-1)); printf("%d\n", t); // printf("%c", t); return 0; }
Output
Here is the output −
109 m 110 n 108 l 1
- Related Articles
- What are the arithmetic and character operators in DBMS?
- Pointer Arithmetic in C/C++
- Arithmetic Operators in C++
- Arithmetic Number in C++
- Arithmetic Mean in c++?
- Arithmetic Slices in C++
- Arithmetic Mean in C programming
- Longest Arithmetic Sequence in C++
- Verbal Arithmetic Puzzle in C++
- What are arithmetic operators in C#?
- Arithmetic Slices II - Subsequence in C++
- Simple Arithmetic Operators Example Program In C++
- Missing Number In Arithmetic Progression using C++
- Binary Number System - Overflow in Arithmetic Addition in C/C++?
- Sum of array using pointer arithmetic in C++

Advertisements