Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » C programming language

Character Constant in C language



C language character constants: In this tutorial, we are going to learn about the character constants with their declarations, printing in C programming language.
Submitted by IncludeHelp, on September 08, 2018

Any character (a single character) that is enclosed within the single quotes (like, 'A') is called character constants in C programming language.

Character constants contain:

  • Any uppercase alphabet
  • Any lowercase alphabet
  • A space
  • A digit
  • Any special character

Character constant declaration

A character constant is declared by using const keyword.

Syntax:

    const char constant_name = 'value';

Example:

#include <stdio.h>

int main(void) 
{
	const char1 = 'A';      //uppercase alphabet
	const char2 = 'X';      //uppercase alphabet 
	const char3 = 'a';      //lowercase alphabet
	const char4 = 'x';      //lowercase alphabet
	const char5 = '5';      //a digit
	const char6 = '#';      //a special character 
	const char7 = ' ';      //a space 

	//print values
	printf("char1 = %c\n", char1);
	printf("char2 = %c\n", char2);
	printf("char3 = %c\n", char3);
	printf("char4 = %c\n", char4);
	printf("char5 = %c\n", char5);
	printf("char6 = %c\n", char5);
	printf("char7 = %c\n", char7);

	return 0;
}

Output

char1 = A
char2 = X
char3 = a
char4 = x
char5 = 5
char6 = 5
char7 =  





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.