SlideShare a Scribd company logo
9
Most read
18
Most read
22
Most read
CONSTANTS, VARIABLES &
DATATYPES
BY
SAHITHI NARAPARAJU
INRODUCTION
• A programming language is designed to help process certain
kinds of data consisting of numbers, characters and strings to
provide useful output known as information.
• The task of processing of data is accomplished by executing a
sequence of precise instructions called program.
• These instructions are formed using certain symbols and
words according to some rigid rules known as syntax rules.
CHARACTER SET:
• The characters in C are grouped into following categories:
1) Letters 2) digits
3) special characters 4) white spaces.
• Compiler ignores white spaces unless they are part of a string
constant.
• White spaces may be used to separate words but prohibited
between characters of keywords and identifiers.
• LETTERS: Uppercase A….Z, lower case a..z.
• DIGITS: All decimal digits 0..9
• SPECIAL CHARACTERS: comma(,), period(.),
semicolon(;) , colon(:), question mark(?), quotation(“), dollar
sign($), slash(/),back slash(), percent sign(%), underscore(_),
ampersand(&), asterisk(*), number sign(#).
• WHITE SPACES: Blank space, Horizontal tab, Carriage
return, Newline, Form feed.
Trigraph characters:
• C introduces the concept of trigraph sequences to provide a
way to enter certain characters that are not available on some
keywords.
• Each trigraph sequence consists of three characters, 2 question
marks followed by another character.
• Eg: ??= (number sign), ??)(right bracket]), ??( (left
bracket[) , ??! (vertical bar), ??< (left brace {) , ??> (right brace
}),??/ (back slash).
C tokens:
•

In a passage of text individual words and punctuation marks
are called tokens.

•

In a C program the smallest individual units known as C
tokens.

•
C has 6 types of tokens namely:
1) Keywords
2) identifiers
3)constants
4)Strings
5)special symbols
6)operators.
Keywords and identifiers.
• Every C word is classified as either a keyword or an identifier.
• All keywords have fixed meanings and these meanings cannot
be changed.
• Keywords serve as basic building blocks for program
statements.
• All keywords must be written in lower case.
• The underscore character is also permitted in identifiers.
• It is usually used a link between two words in long identifiers
RULES FOR IDENTIFIERS:
1.
2.
3.
4.
5.

First character must be an alphabet.
Must consist of only letters, digits or underscore.
Only first 31 characters are significant.
Cannot use keyword.
Must not contain white space.
CONSTANTS
• Constants refer to fixed values that do not change during the
execution of program.

INTEGER CONSTANTS:
• An integer constant refer to a sequence of digits.
• There are 3 types of integers namely:
Decimal integer, octal integer and hexadecimal integer.
• Decimal integer consist of a set of digits 0 through
9,precceded by an optional – or + sign.
• An octal integer constant consist of any combination of digits
from the set 0 through 7. with a leading 0
• Eg: 037,0, 0456.
• A sequence of digits preceded by 0x or 0X is considered as
hexadecimal integer.
• They may include alphabets A through F or f.
• Letter A through F represents numbesr 10 to 15.
REAL CONSTANTS:
• To represent quantities that vary continuously real constants
are used.
• A real number may be expressed in exponential notation.
SYNTAX: mantissa e exponent.
• Mantissa can be either real number expressed in decimal
notation or an integer.
• Exponent is an integer number with an optional + or – sign.
• The letter ‘e’ separating the mantissa and the exponent, it can
be written either lower case or upper case.
SYNTAX: 0.65e4,12e-2.
• White space is not allowed.
• Exponential notation is useful for representing numbers that
are either very large or very small in magnitude.
• Floating point constants are normally represented as doubleprecision quantities.

SINGLE CHARACTER CONSTANTS:
• A single character constant contains a single character enclose
in a pair of single quote marks.
Eg: ‘5’,’x’.
• Character constant ‘5’ is not same as number 5.
• Character constants have integer values known as ASCII
values.
• Statement: printf (“%d”, ’a’); would print number 97, the
ASCII value of letter ‘a’.
• Since each character constant represent an integer value, it is
possible to perform arithmetic operations on character
constants.
STRING CONSTANTS:
• A string constant is a sequence of characters enclosed in
double quotes.
• Characters may be letters, numbers, special characters and
blank spaces.
Eg: “hello” , “1987”, “?...!”.
• Character constant is not equivalent to single character string
constant.

.
BACK SLASH CHARACTER CONSTANTS:
• C supports some special back slash character constants that
are used in output functions.
• These characters combinations are known as escape
sequences.
• Back slash character constants are:
‘a’ audible alert; ‘b’ backspace; ‘f’ form feed; ‘n’ newline;
‘r’ carriage return; ‘t’ horizontal tab; ‘v’ vertical tab;
‘”single quote, ‘?’ question mark; ‘’ backslash; ‘0’ null.
VARIABLES
•

A variable is a data name that may be used to store a data
value.

•

A variable may take different values at different times
during execution.

•

A variable can be chosen by the programmer in a
meaningful way.

CONDITIONS FOR SPECIFYING VARIABLES:
1.

They must begin with a letter. Some systems may permit
underscore as first character.
1.

Uppercase and lowercase are significant. The variable
TOTAL is different from total and Total.

2.

It should not be keyword.

3.

Whitespace is not allowed.

4.

Length should be normally more than 8 characters are
treated as significant by many compilers.

•

Examples of valid variables are:
john, x1,T_raise, first_tag.

•

Examples of invalid variables are:
123,(area),25th,price$, %.
DATATYPES
• C language is rich in its data types.
• Storage representations and machine instructions to handle
constants differ from machine to machine.
• The variety of datatypes allow to select the type appropriate to
the needs of the application as well as machine.
• C supports 3 classes of datatypes:
1)Primary datatypes
2) derived datatypes
3)derived datatypes.
• All C compilers support 5 fundamental datatypes namely:
integer (int), character (char), floating point (float), doubleprecision floating point (double) and void.
• Many of them also offer extended datatypes such as long int,
int ,long double.
Data type
Range of values
char
-128 to 127
int
-32768 to 32767
float
-3.4e+8 to 3.4e+8
double
1.7e-308 to 1.7e+308.
INTEGER TYPES:
• Integers are whole numbers with a range of values supported
by particular machine.
• Integers occupy one word storage generally and since the
word sizes of machine vary the size of integer that can be
stored depends on computer.
• If we use 16-bit word length, the size of integer value is
limited to range -32768 to 32767.
• If we use 32-bit word length can store an integer ranging from
-2147483648 to 2147483647.
• In order to provide control over range of numbers and storage
space C has 3 classes of integer storage namely: short int, int,
long int in both signed and unsigned.
• Short int represents fairly small integer values and requires
half amount as regular int number uses.

FLOATING POINT TYPE:
•

Floating point numbers are stored in 32bits, with 6 digit
precision.

• Floating point numbers are defined by keyword “float”.
• When accuracy is provided by a float number is not sufficient,
double can be used to define number.
• A double datatype number uses 64 bits giving a precision of
14 digits.
• These are known as double precision number.
• Double datatype represent the same datatype that float
represents but with greater precision.
• To extend the precision we may use long double which uses
80 bits.
VOID TYPES:
• Void type has no values. This is used to specify the type of
functions.
• The type of function is said to be void when it doesn't return
any value to the calling function.

CHARACTER TYPES:
• A single character can be defined as a character (char) type
data.
• Characters are usually store in one byte of internal storage.
• Qualifier signed or unsigned may be used in char explicitly.
Unsigned characters have values between 0 and 255, signed
characters have values from -128 to 127

More Related Content

PPTX
Data Type in C Programming
Qazi Shahzad Ali
 
PPTX
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
PPT
C program
AJAL A J
 
PPT
Constants in C Programming
programming9
 
DOCX
Basic structure of c programming
TejaswiB4
 
PPTX
Data types in C
Ansh Kashyap
 
PPT
RECURSION IN C
v_jk
 
PPTX
Operators and expressions in c language
tanmaymodi4
 
Data Type in C Programming
Qazi Shahzad Ali
 
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
C program
AJAL A J
 
Constants in C Programming
programming9
 
Basic structure of c programming
TejaswiB4
 
Data types in C
Ansh Kashyap
 
RECURSION IN C
v_jk
 
Operators and expressions in c language
tanmaymodi4
 

What's hot (20)

PPTX
Data types in C
Tarun Sharma
 
PPTX
C tokens
Manu1325
 
PPTX
Pointer in c
lavanya marichamy
 
PPTX
Preprocessor directives in c language
tanmaymodi4
 
PPTX
C Programming: Control Structure
Sokngim Sa
 
PPTX
Arrays in c
Jeeva Nanthini
 
PPTX
Data types in python
RaginiJain21
 
PPTX
Conditional Statement in C Language
Shaina Arora
 
PPT
Array in c
Ravi Gelani
 
PPTX
Enums in c
Vijayananda Ratnam Ch
 
PPTX
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
PPT
Variables in C Programming
programming9
 
PPTX
Function in C program
Nurul Zakiah Zamri Tan
 
PPTX
Pointers in c++
sai tarlekar
 
PPTX
Control statements in c
Sathish Narayanan
 
PPTX
Variables in C++, data types in c++
Neeru Mittal
 
PPTX
Infix to postfix conversion
Then Murugeshwari
 
PPTX
C pointer
University of Potsdam
 
PPTX
Pointer in C++
Mauryasuraj98
 
PPTX
Tokens in C++
Mahender Boda
 
Data types in C
Tarun Sharma
 
C tokens
Manu1325
 
Pointer in c
lavanya marichamy
 
Preprocessor directives in c language
tanmaymodi4
 
C Programming: Control Structure
Sokngim Sa
 
Arrays in c
Jeeva Nanthini
 
Data types in python
RaginiJain21
 
Conditional Statement in C Language
Shaina Arora
 
Array in c
Ravi Gelani
 
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Variables in C Programming
programming9
 
Function in C program
Nurul Zakiah Zamri Tan
 
Pointers in c++
sai tarlekar
 
Control statements in c
Sathish Narayanan
 
Variables in C++, data types in c++
Neeru Mittal
 
Infix to postfix conversion
Then Murugeshwari
 
Pointer in C++
Mauryasuraj98
 
Tokens in C++
Mahender Boda
 
Ad

Viewers also liked (10)

PPTX
Constants and variables in c programming
Chitrank Dixit
 
PPTX
Presentation on literature review
Karna Bahadur Chongbang
 
PPTX
The Literature Review Process
annielibrarian
 
PPTX
Concept, Construct and Variable
Dr. Anamika Ray Memorial Trust
 
PPT
The research instruments
Yolanda Sobrepena
 
PPTX
Ethical issues in research
R.Harish Kumar
 
PPTX
Educational research
meenuch
 
PDF
Literature Review
Anaika Alexander
 
PPTX
Characteristics and criteria of good research
A B
 
PPSX
Literature review in research
Nursing Path
 
Constants and variables in c programming
Chitrank Dixit
 
Presentation on literature review
Karna Bahadur Chongbang
 
The Literature Review Process
annielibrarian
 
Concept, Construct and Variable
Dr. Anamika Ray Memorial Trust
 
The research instruments
Yolanda Sobrepena
 
Ethical issues in research
R.Harish Kumar
 
Educational research
meenuch
 
Literature Review
Anaika Alexander
 
Characteristics and criteria of good research
A B
 
Literature review in research
Nursing Path
 
Ad

Similar to constants, variables and datatypes in C (20)

PPT
C presentation book
krunal1210
 
PPTX
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University
 
PPTX
Btech i pic u-2 datatypes and variables in c language
Rai University
 
PPTX
Mca i pic u-2 datatypes and variables in c language
Rai University
 
PDF
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
PPTX
Bsc cs i pic u-2 datatypes and variables in c language
Rai University
 
PPTX
datatypes and variables in c language
Rai University
 
PDF
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
PPTX
Constant, variables, data types
Pratik Devmurari
 
PPT
C the basic concepts
Abhinav Vatsa
 
PPT
All C ppt.ppt
JeelBhanderi4
 
PPTX
Module 1:Introduction
nikshaikh786
 
PDF
C Tutorial
Dr.Subha Krishna
 
PPTX
Introduction to C language programming.pptx
OVIDMAMAH
 
PPTX
Basic of Structered Programming in C psd
YogaBalajee1
 
PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PPTX
C
PRADEEPA R
 
PPTX
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
PDF
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
PPTX
Introduction to c programming
SaranyaK68
 
C presentation book
krunal1210
 
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University
 
Btech i pic u-2 datatypes and variables in c language
Rai University
 
Mca i pic u-2 datatypes and variables in c language
Rai University
 
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
Bsc cs i pic u-2 datatypes and variables in c language
Rai University
 
datatypes and variables in c language
Rai University
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
Constant, variables, data types
Pratik Devmurari
 
C the basic concepts
Abhinav Vatsa
 
All C ppt.ppt
JeelBhanderi4
 
Module 1:Introduction
nikshaikh786
 
C Tutorial
Dr.Subha Krishna
 
Introduction to C language programming.pptx
OVIDMAMAH
 
Basic of Structered Programming in C psd
YogaBalajee1
 
Data Types and Variables In C Programming
Kamal Acharya
 
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
Introduction to c programming
SaranyaK68
 

More from Sahithi Naraparaju (16)

PPT
PPT FOR IDBSDDS SCHEMES
Sahithi Naraparaju
 
DOC
documentation for identity based secure distrbuted data storage schemes
Sahithi Naraparaju
 
PPT
SYSTEM ARCHITECTURE / UML DIAGRAMS FOR IDENTITY BASED SECURE DISTRIBUTED DATA...
Sahithi Naraparaju
 
PPT
over view of viruses
Sahithi Naraparaju
 
PPT
literature survey for identity based secure distributed data storage
Sahithi Naraparaju
 
PPT
Identity based secure distributed data storage schemes
Sahithi Naraparaju
 
DOC
Srs document for identity based secure distributed data storage schemes
Sahithi Naraparaju
 
PPT
66913017 java-ring-1217949449014046-9 (1)
Sahithi Naraparaju
 
PPTX
Self protecteion in clustered distributed system new
Sahithi Naraparaju
 
PPT
OVERVIEW OF ‘C’ PROGRAM
Sahithi Naraparaju
 
PPT
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju
 
PPT
Steps for Developing a 'C' program
Sahithi Naraparaju
 
PPT
pre processor directives in C
Sahithi Naraparaju
 
PPTX
Self protecteion in clustered distributed system new
Sahithi Naraparaju
 
PPTX
A Batch-authenticated And Key Agreement Framework For P2p-based Online Social...
Sahithi Naraparaju
 
PPT
Haptic technology
Sahithi Naraparaju
 
PPT FOR IDBSDDS SCHEMES
Sahithi Naraparaju
 
documentation for identity based secure distrbuted data storage schemes
Sahithi Naraparaju
 
SYSTEM ARCHITECTURE / UML DIAGRAMS FOR IDENTITY BASED SECURE DISTRIBUTED DATA...
Sahithi Naraparaju
 
over view of viruses
Sahithi Naraparaju
 
literature survey for identity based secure distributed data storage
Sahithi Naraparaju
 
Identity based secure distributed data storage schemes
Sahithi Naraparaju
 
Srs document for identity based secure distributed data storage schemes
Sahithi Naraparaju
 
66913017 java-ring-1217949449014046-9 (1)
Sahithi Naraparaju
 
Self protecteion in clustered distributed system new
Sahithi Naraparaju
 
OVERVIEW OF ‘C’ PROGRAM
Sahithi Naraparaju
 
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju
 
Steps for Developing a 'C' program
Sahithi Naraparaju
 
pre processor directives in C
Sahithi Naraparaju
 
Self protecteion in clustered distributed system new
Sahithi Naraparaju
 
A Batch-authenticated And Key Agreement Framework For P2p-based Online Social...
Sahithi Naraparaju
 
Haptic technology
Sahithi Naraparaju
 

Recently uploaded (20)

PDF
GYTPOL If You Give a Hacker a Host
linda296484
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Software Development Methodologies in 2025
KodekX
 
PPTX
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Captain IT
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
GYTPOL If You Give a Hacker a Host
linda296484
 
This slide provides an overview Technology
mineshkharadi333
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Software Development Methodologies in 2025
KodekX
 
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Captain IT
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 

constants, variables and datatypes in C

  • 2. INRODUCTION • A programming language is designed to help process certain kinds of data consisting of numbers, characters and strings to provide useful output known as information. • The task of processing of data is accomplished by executing a sequence of precise instructions called program. • These instructions are formed using certain symbols and words according to some rigid rules known as syntax rules.
  • 3. CHARACTER SET: • The characters in C are grouped into following categories: 1) Letters 2) digits 3) special characters 4) white spaces. • Compiler ignores white spaces unless they are part of a string constant. • White spaces may be used to separate words but prohibited between characters of keywords and identifiers.
  • 4. • LETTERS: Uppercase A….Z, lower case a..z. • DIGITS: All decimal digits 0..9 • SPECIAL CHARACTERS: comma(,), period(.), semicolon(;) , colon(:), question mark(?), quotation(“), dollar sign($), slash(/),back slash(), percent sign(%), underscore(_), ampersand(&), asterisk(*), number sign(#). • WHITE SPACES: Blank space, Horizontal tab, Carriage return, Newline, Form feed.
  • 5. Trigraph characters: • C introduces the concept of trigraph sequences to provide a way to enter certain characters that are not available on some keywords. • Each trigraph sequence consists of three characters, 2 question marks followed by another character. • Eg: ??= (number sign), ??)(right bracket]), ??( (left bracket[) , ??! (vertical bar), ??< (left brace {) , ??> (right brace }),??/ (back slash).
  • 6. C tokens: • In a passage of text individual words and punctuation marks are called tokens. • In a C program the smallest individual units known as C tokens. • C has 6 types of tokens namely: 1) Keywords 2) identifiers 3)constants 4)Strings 5)special symbols 6)operators.
  • 7. Keywords and identifiers. • Every C word is classified as either a keyword or an identifier. • All keywords have fixed meanings and these meanings cannot be changed. • Keywords serve as basic building blocks for program statements. • All keywords must be written in lower case. • The underscore character is also permitted in identifiers. • It is usually used a link between two words in long identifiers
  • 8. RULES FOR IDENTIFIERS: 1. 2. 3. 4. 5. First character must be an alphabet. Must consist of only letters, digits or underscore. Only first 31 characters are significant. Cannot use keyword. Must not contain white space.
  • 9. CONSTANTS • Constants refer to fixed values that do not change during the execution of program. INTEGER CONSTANTS: • An integer constant refer to a sequence of digits. • There are 3 types of integers namely: Decimal integer, octal integer and hexadecimal integer. • Decimal integer consist of a set of digits 0 through 9,precceded by an optional – or + sign.
  • 10. • An octal integer constant consist of any combination of digits from the set 0 through 7. with a leading 0 • Eg: 037,0, 0456. • A sequence of digits preceded by 0x or 0X is considered as hexadecimal integer. • They may include alphabets A through F or f. • Letter A through F represents numbesr 10 to 15.
  • 11. REAL CONSTANTS: • To represent quantities that vary continuously real constants are used. • A real number may be expressed in exponential notation. SYNTAX: mantissa e exponent. • Mantissa can be either real number expressed in decimal notation or an integer. • Exponent is an integer number with an optional + or – sign. • The letter ‘e’ separating the mantissa and the exponent, it can be written either lower case or upper case. SYNTAX: 0.65e4,12e-2.
  • 12. • White space is not allowed. • Exponential notation is useful for representing numbers that are either very large or very small in magnitude. • Floating point constants are normally represented as doubleprecision quantities. SINGLE CHARACTER CONSTANTS: • A single character constant contains a single character enclose in a pair of single quote marks. Eg: ‘5’,’x’.
  • 13. • Character constant ‘5’ is not same as number 5. • Character constants have integer values known as ASCII values. • Statement: printf (“%d”, ’a’); would print number 97, the ASCII value of letter ‘a’. • Since each character constant represent an integer value, it is possible to perform arithmetic operations on character constants.
  • 14. STRING CONSTANTS: • A string constant is a sequence of characters enclosed in double quotes. • Characters may be letters, numbers, special characters and blank spaces. Eg: “hello” , “1987”, “?...!”. • Character constant is not equivalent to single character string constant. .
  • 15. BACK SLASH CHARACTER CONSTANTS: • C supports some special back slash character constants that are used in output functions. • These characters combinations are known as escape sequences. • Back slash character constants are: ‘a’ audible alert; ‘b’ backspace; ‘f’ form feed; ‘n’ newline; ‘r’ carriage return; ‘t’ horizontal tab; ‘v’ vertical tab; ‘”single quote, ‘?’ question mark; ‘’ backslash; ‘0’ null.
  • 16. VARIABLES • A variable is a data name that may be used to store a data value. • A variable may take different values at different times during execution. • A variable can be chosen by the programmer in a meaningful way. CONDITIONS FOR SPECIFYING VARIABLES: 1. They must begin with a letter. Some systems may permit underscore as first character.
  • 17. 1. Uppercase and lowercase are significant. The variable TOTAL is different from total and Total. 2. It should not be keyword. 3. Whitespace is not allowed. 4. Length should be normally more than 8 characters are treated as significant by many compilers. • Examples of valid variables are: john, x1,T_raise, first_tag. • Examples of invalid variables are: 123,(area),25th,price$, %.
  • 18. DATATYPES • C language is rich in its data types. • Storage representations and machine instructions to handle constants differ from machine to machine. • The variety of datatypes allow to select the type appropriate to the needs of the application as well as machine. • C supports 3 classes of datatypes: 1)Primary datatypes 2) derived datatypes 3)derived datatypes.
  • 19. • All C compilers support 5 fundamental datatypes namely: integer (int), character (char), floating point (float), doubleprecision floating point (double) and void. • Many of them also offer extended datatypes such as long int, int ,long double. Data type Range of values char -128 to 127 int -32768 to 32767 float -3.4e+8 to 3.4e+8 double 1.7e-308 to 1.7e+308.
  • 20. INTEGER TYPES: • Integers are whole numbers with a range of values supported by particular machine. • Integers occupy one word storage generally and since the word sizes of machine vary the size of integer that can be stored depends on computer. • If we use 16-bit word length, the size of integer value is limited to range -32768 to 32767. • If we use 32-bit word length can store an integer ranging from -2147483648 to 2147483647.
  • 21. • In order to provide control over range of numbers and storage space C has 3 classes of integer storage namely: short int, int, long int in both signed and unsigned. • Short int represents fairly small integer values and requires half amount as regular int number uses. FLOATING POINT TYPE: • Floating point numbers are stored in 32bits, with 6 digit precision. • Floating point numbers are defined by keyword “float”.
  • 22. • When accuracy is provided by a float number is not sufficient, double can be used to define number. • A double datatype number uses 64 bits giving a precision of 14 digits. • These are known as double precision number. • Double datatype represent the same datatype that float represents but with greater precision. • To extend the precision we may use long double which uses 80 bits.
  • 23. VOID TYPES: • Void type has no values. This is used to specify the type of functions. • The type of function is said to be void when it doesn't return any value to the calling function. CHARACTER TYPES: • A single character can be defined as a character (char) type data. • Characters are usually store in one byte of internal storage. • Qualifier signed or unsigned may be used in char explicitly. Unsigned characters have values between 0 and 255, signed characters have values from -128 to 127