Home C Programming Language / Programs / Character constant in c program
🚀 Programming Example

Character constant in c program

👁 1,279 Views
💻 Practical Program
📘 Step Learning

A character constant is a single character, enclosed in single quotation marks.

e.g., ‘A’  ‘B’ ‘1’

💻 Program Code

#include<stdio.h>
#include<conio.h>
int main()
{
const char a = ‘X’;
clrscr();
printf(“Value of a  = %c  , a ”);
getch();
return 0;
}
                        

🖥 Program Output


Value of a = X
                            

📘 Explanation

A character constant is a single character, enclosed in single quotation marks.

e.g., ‘A’  ‘B’ ‘1’

Characters are stored internally in computer as coded set of binary digits, which have positive decimal integer equivalents. The value of a character constant is the numeric value of the character in the machine’s character set. This means that the value of a character constants can vary from one machine to the next, depending on the character set being used on the particular machine. For example, on ASCII machine the value of ‘A’ is 65 and on EBCDIC machine it is 193.

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.