Character Arithmetic in C Last Updated : 26 Dec, 2023 Comments Improve Suggest changes Like Article Like Report As already known character range is between -128 to 127 or 0 to 255. This point has to be kept in mind while doing character arithmetic. What is Character Arithmetic?Character arithmetic is used to implement arithmetic operations like addition, subtraction, multiplication, and division on characters in C language. In character arithmetic character converts into an integer value to perform the task. For this ASCII value is used.It is used to perform actions on the strings. To understand better let's take an example. Example 1 C // C program to demonstrate character arithmetic. #include <stdio.h> int main() { char ch1 = 125, ch2 = 10; ch1 = ch1 + ch2; printf("%d\n", ch1); printf("%c\n", ch1 - ch2 - 4); return 0; } Output-121 y So %d specifier causes an integer value to be printed and %c specifier causes a character value to printed. But care has to taken that while using %c specifier the integer value should not exceed 127. Let's take one more example. Example 2 C #include <stdio.h> // driver code int main(void) { char value1 = 'a'; char value2 = 'b'; char value3 = 'z'; // perform character arithmetic char num1 = value1 + 3; char num2 = value2 - 1; char num3 = value3 + 2; // print value printf("numerical value=%d\n", num1); printf("numerical value=%d\n", num2); printf("numerical value=%d\n", num3); return 0; } Outputnumerical value=100 numerical value=97 numerical value=124 Example 3 C #include <stdio.h> int main() { char a = 'A'; char b = 'B'; printf("a = %c\n", a); printf("b = %c\n", b); printf("a + b = %c\n", a + b); return 0; } Outputa = Ab = Ba + b = âExplanation In this program, two character variables a and b are declared and assigned the values 'A' and 'B', respectively. The program then adds a and b using character arithmetic, which results 'â'. The result is then printed using the printf() function.Note that in character arithmetic, the characters are treated as integers based on their ASCII code values. For example, the ASCII code for 'A' is 65 and for 'B' is 66, so adding 'A' and 'B' results in 65 + 66 = 131, which is the ASCII code for 'â'. Comment More infoAdvertise with us _Parveen Kumar Follow Improve Article Tags : C Language cpp-data-types Explore C Programming Language Tutorial 4 min read C BasicsC Language Introduction 6 min read Features of C Programming Language 3 min read C Programming Language Standard 6 min read C Hello World Program 1 min read Compiling a C Program: Behind the Scenes 4 min read C Comments 3 min read Tokens in C 4 min read Keywords in C 2 min read C Variables and ConstantsC Variables 4 min read Constants in C 4 min read Const Qualifier in C 6 min read Different ways to declare variable as constant in C 2 min read Scope rules in C 5 min read Internal Linkage and External Linkage in C 4 min read Global Variables in C 3 min read C Data TypesData Types in C 5 min read Literals in C 4 min read Escape Sequence in C 5 min read bool in C 5 min read Integer Promotions in C 2 min read Character Arithmetic in C 2 min read Type Conversion in C 4 min read C Input/OutputBasic Input and Output in C 4 min read Format Specifiers in C 5 min read printf in C 5 min read scanf in C 3 min read Scansets in C 2 min read Formatted and Unformatted Input/Output in C 6 min read C OperatorsOperators in C 11 min read Arithmetic Operators in C 5 min read Unary Operators in C 5 min read Relational Operators in C 4 min read Bitwise Operators in C 6 min read C Logical Operators 4 min read Assignment Operators in C 4 min read Increment and Decrement Operators in C 4 min read Conditional or Ternary Operator (?:) in C 3 min read sizeof operator in C 3 min read Operator Precedence and Associativity in C 7 min read C Control Statements Decision-MakingDecision Making in C (if , if..else, Nested if, if-else-if ) 7 min read C - if Statement 4 min read C if else Statement 3 min read C if , else if ladder 4 min read Switch Statement in C 5 min read Using Range in switch Case in C 2 min read C - Loops 6 min read C for Loop 4 min read while Loop in C 5 min read do...while Loop in C 4 min read For vs. While 4 min read Continue Statement in C 4 min read Break Statement in C 5 min read goto Statement in C 4 min read C FunctionsC Functions 6 min read User-Defined Function in C 6 min read Parameter Passing Techniques in C 3 min read Function Prototype in C 4 min read How can I return multiple values from a function? 3 min read main Function in C 5 min read Implicit Return Type int in C 2 min read Callbacks in C 4 min read Nested Functions in C 4 min read Variadic Functions in C 5 min read _Noreturn function specifier in C 2 min read Predefined Identifier __func__ in C 2 min read C Library math.h Functions 6 min read C Arrays & StringsC Arrays 7 min read Properties of Array in C 7 min read Multidimensional Arrays in C - 2D and 3D Arrays 8 min read Initialization of Multidimensional Array in C 4 min read Pass Array to Functions in C 3 min read How to pass a 2D array as a parameter in C? 3 min read What are the data types for which it is not possible to create an array? 2 min read How to pass an array by value in C ? 2 min read Strings in C 6 min read Array of Strings in C 3 min read What is the difference between single quoted and double quoted declaration of char array? 2 min read C String Functions 6 min read C PointersC Pointers 9 min read Pointer Arithmetics in C with Examples 10 min read C - Pointer to Pointer (Double Pointer) 5 min read Function Pointer in C 6 min read How to Declare a Pointer to a Function? 2 min read Pointer to an Array | Array Pointer 5 min read Difference between constant pointer, pointers to constant, and constant pointers to constants 3 min read Pointer vs Array in C 1 min read Dangling, Void , Null and Wild Pointers in C 6 min read Near, Far and Huge Pointers in C 4 min read restrict Keyword in C 3 min read Like