0% found this document useful (0 votes)
115 views2 pages

Character and Character Set 1 - What Is A Character, What Is Character Set in C Programming Define and Explain With Suitable Examples

The document discusses characters and character sets in C programming. It defines a character as the basic unit of textual information stored as a single byte representing a letter, digit, symbol or special character. A character set is the collection of valid characters for a C program, including the source character set used for writing code and the execution character set processed during runtime. Common characters in C are listed along with the typical source character set and information on how characters are represented internally through ASCII codes and character literals.

Uploaded by

kgmmet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views2 pages

Character and Character Set 1 - What Is A Character, What Is Character Set in C Programming Define and Explain With Suitable Examples

The document discusses characters and character sets in C programming. It defines a character as the basic unit of textual information stored as a single byte representing a letter, digit, symbol or special character. A character set is the collection of valid characters for a C program, including the source character set used for writing code and the execution character set processed during runtime. Common characters in C are listed along with the typical source character set and information on how characters are represented internally through ASCII codes and character literals.

Uploaded by

kgmmet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Here's a comprehensive explanation of characters and character sets in C programming:

Character:

● It's the basic unit of textual information in C programming.


● It represents a single letter, digit, symbol, or special character.
● It's stored as a single byte in memory, holding a numeric value corresponding to a specific
character in the character set.

Character Set:

● It's the collection of all valid characters that can be used in C programs.
● C supports two types of character sets:
1. Source Character Set (SCS):
■ The characters used to write the source code of a program.
■ It usually includes ASCII characters (128 characters) but can be extended.
2. Execution Character Set (ECS):
■ The characters a C program can process during execution.
■ It might include more characters than the SCS, depending on the system and
encoding.

Examples of Characters in C:

● Letters: 'a', 'B', 'Z'


● Digits: '0', '5', '9'
● Symbols: '+', '-', '*', '/'
● Special Characters: ' ' (space), '\n' (newline), '\t' (tab)

Typical SCS in C:

● Lowercase letters: a-z


● Uppercase letters: A-Z
● Digits: 0-9
● Punctuation marks: , . ; : ? ! " ' ( ) [ ] { }
● Arithmetic operators: + - * / %
● Assignment operator: =
● Relational operators: == != < > <= >=
● Logical operators: && || !
● Special characters: _ # $ & @ \ ~ ^ | `
● White space characters: space, tab, newline

Key Points:

● C internally represents characters using their ASCII codes (numeric values).


● You can use character literals (e.g., 'A') or escape sequences (e.g., '\n') to represent
characters in code.
● The ctype.h header provides functions for character classification and manipulation (e.g.,
isalpha, isdigit, toupper, tolower).

Example Code:

C
#include <stdio.h>

int main() {
char letter = 'C';
int ascii_code = letter; // ASCII code of 'C' is 67

printf("Character: %c\n", letter);


printf("ASCII code: %d\n", ascii_code);

return 0;
}

You might also like