0% found this document useful (0 votes)
39 views18 pages

C S Basic Terminologies PPA

This document discusses basic terminology in C programming, including character sets, tokens, keywords, identifiers, literals, integer constants, floating/real constants, and character constants. It defines each term and provides examples. Character sets include letters, digits, symbols, and whitespace. The smallest units in a program are tokens such as keywords, identifiers, literals, punctuators, and operators. There are 32 reserved keywords in C that have special meaning. Identifiers are user-defined names that follow specific naming rules. Literals represent fixed data values of different types, including integers without decimals, floating-point numbers, and single characters.

Uploaded by

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

C S Basic Terminologies PPA

This document discusses basic terminology in C programming, including character sets, tokens, keywords, identifiers, literals, integer constants, floating/real constants, and character constants. It defines each term and provides examples. Character sets include letters, digits, symbols, and whitespace. The smallest units in a program are tokens such as keywords, identifiers, literals, punctuators, and operators. There are 32 reserved keywords in C that have special meaning. Identifiers are user-defined names that follow specific naming rules. Literals represent fixed data values of different types, including integers without decimals, floating-point numbers, and single characters.

Uploaded by

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

C Basic Terminology

-Shubham Panchal(IIT Hyderabad)


Character Set
A character set is a set of valid characters that a language can recognize.
A character represents any letter, digit, or any other sign. C has the
following character set:
 Letters: A-Z, a-z.
 Digits: 0-9.
 Special Symbols: Space + - * / ^ \ ( ) [ ] = ! < > . ‘ ’ “ ” $ , ; : % & | ?
_(underscore) # <= >= @
 White Spaces: Blank space, horizontal tab, carriage return , newline.

Panchal's Programming Academy


Character Set
 Other Characters: C can also process any of the 256 ASCII characters
as data or as literals.
ASCII Table:
ASCII stands for American Standard Code for Information
Interchange.
https://panchalshubham.github.io/shubhampanchal.github.io/Files/HTM
L/ASCIITable.html

Panchal's Programming Academy


Tokens
The smallest individual unit in a program is known as Token.
C has the following tokens:
Keywords, Identifiers, Literals, Punctuators and Operators.

Panchal's Programming Academy


Keywords
The keywords are the reserved words that convey a special meaning to
the language compiler.
auto break case char
const continue default do
double else enum extern There are
float for goto if 32
int long register return
short signed sizeof static
keywords in
struct switch typedef union C-language.
unsigned void volatile while

Panchal's Programming Academy


Keywords
Keywords are the words whose meaning has been already explained to
the C Compiler.
The keywords cannot be used as identifiers because if we do so then we
are trying to assign a new meaning to the keyword, which is not
allowed.

Panchal's Programming Academy


Identifiers
An identifier is the name given by the user for a unit of the program.
Rules for Identifiers:
1) An identifier can contain alphabets and digits.
2) The first character of an identifier must be an alphabet or an
underscore(_ ).
3) C is case sensitive i.e. it treats upper and lower case characters
differently. For example, A and a are different characters for C.

Panchal's Programming Academy


Identifiers
4) A reserved keyword cannot be used as an identifier.
5) An identifier should not contain any special character except
_(underscore).
Valid Identifiers Invalid Identifiers
MyFile My File(Spaces is not allowed)
DATE9_7_77 DATE9-7-77(Special characters are not allowed)
File13 13File(An identifier cannot start with digit)
_CHK @CHK(Special symbol except _ are not allowed)
For for(keywords cannot be used as identifier)

Panchal's Programming Academy


Literals
Literals(often referred to as constants) are data items that never change
their value during a program run.
C allows several kind of literals:
i. Integer constants
ii. Floating or Real constants
iii. Character constants

Panchal's Programming Academy


Integer Constants
Integer constants are whole numbers without any fractional part.
Rule for writing integer constants:
An integer constant must have at least one digit.
It must not have a decimal point.
It may contain a + or – sign. An integer constant with no sign is
assumed to be positive.
No commas or blanks are allowed for integer constants.

Panchal's Programming Academy


Integer Constants
C allows three types of Integer constants:
a. Decimal Integer constants: An integer constant consisting of a
sequence of digits is taken to be decimal integer constant unless it
begins with 0(digit 0). For example, 1234, 41, +97, -17, etc. are
decimal integer constants.
b. Octal Integer constants: A sequence of digit starting with 0(digit 0)
is taken to be an octal integer. For example, decimal integer 8 will be
written as 010 as octal integer and decimal integer 12 will be written
as 014 as octal integer.

Panchal's Programming Academy


Integer Constants
When you start a number with 0(zero), make sure that digits 8 and 9 are
not included as octal numbers recognize digits 0-7 only. Therefore,
numbers like digit 0891, or 068 or 023, etc. are illegal numbers and your
program may behave erratically upon encountering such numbers.
c. Hexadecimal Integer constants: A sequence of digits preceded by 0x
or 0X is taken to be hexadecimal integer. For example, decimal 12 will
be written as 0XC as hexadecimal integer.

Panchal's Programming Academy


Floating or Real Constants
Real constants are numbers having fractional parts. Real constants can
be written in two forms i.e. Fractional form or exponential form.
Rules for writing fractional form real constants:
A real constant must have at least one digit.
It must have a decimal point.
It could be either positive or negative. If no sign is supplied then it is
considered as positive.
No commas or blanks are allowed within real constants.

Panchal's Programming Academy


Floating or Real Constants
In exponential form, real constants are written in two parts. The part
appearing before ‘e’ or ‘E’ is called the mantissa and the part following
the ‘e’ or ‘E’ is called the exponent.
Rules for writing exponential form real constants:
The mantissa and the exponent part should be separated by ‘e’ or ‘E’.
Both mantissa and the exponent can be positive or negative. If no sign
is supplied then it is considered as positive.
Exponent must have at least one integer.

Panchal's Programming Academy


Floating or Real Constants
Fractional Form :
Valid: 2.0, 17.5, -13.0, -0.000625, etc.
Invalid:
7(no decimal point)
7. (no digit after decimal point)
+17/2 (/-illegal symbol)
17250.26.2 (Two decimal points)
17,250.262(Comma not allowed).

Panchal's Programming Academy


Floating or Real Constants
Exponential Form :
Valid:152E05,1.52e07,0.1523E-8,152e+8, etc.
Invalid:
172.E5(at least one digit must follow the decimal point)
1.7e (no digit specified for exponent)
0.172E2.3 (Exponent cannot have fractional part)
17250,26E2 (No comma allowed)
.25E3(No Preceding digit before decimal point).

Panchal's Programming Academy


Character Constants
A character constant is a single character enclosed in single quotes. For
example ’a’.
Non graphic characters can be represented by using escape sequences.
An escape sequence is represented by a backslash(\) followed by one or
more characters.

Panchal's Programming Academy


Escape Sequences
Escape Sequence Non graphic Escape Sequence Non graphic
character character
\a Audible bell \\ Backslash
\b Backspace \’ Single Quotes
\f Formfeed \” Double Quotes
\n Newline \? Question Mark
\r Carriage return \0 Octal number
\t Horizontal Tab \x Hexadecimal number
\v Vertical Tab \0 Null character

Panchal's Programming Academy

You might also like