SlideShare a Scribd company logo
2
Most read
3
Most read
13
Most read
Constant ,Variables & Data Types
Constant:-
• Constant is C refer to fixed value that do not change during the
execution of a program. C supports several types of constant.
1) Integer constants
2) Real constants
3) Single character constant
4) String constant
Integer constant:-
• An integer constant refers to a sequence of digits. There are three types of integer
,namely ,decimal integer ,octal integer ,hexadecimal integer.
• Decimal integer consist of a set of digit, 0 through 9, preceded by an optional – or
+ sign. Examples:- 123,-321,0,654321,+78
• Embedded spaces, commas, and non-digit character are not permitted between
digits. For examples:-15750,20000,$1000
• A sequence of digits preceded by 0x or oX is considered as hexadecimal integer.
They may also include alphabets A through f. the letter A through F represent the
numbers 10 through 15. Examples:-0X2 ,0x9F ,0Xbcd ,0x
• We rarely use octal and hexadecimal numbers in programing.
• The largest integer value that can be stored in machine-dependent. It is 32767 on
16-bit machines and 2,147,483,647 on 32 bit- machines.
Real constants:-
• Integer number are inadequate quantities that vary continuously, such as distances,
heights, temperature, prices, and so on. These quantities are represented by
numbers containing fractional parts like 17.548. such numbers are called real
constants.
• These numbers are shown in decimal notation, having a whole number followed
by a decimal point and the fractional part.
• A real number may also be expressed in exponential notation. For example, the
value 215.65 may be written as 2.165e2 in exponential notation. e2 means
multiply by 10*10.
• The mantissa is either a real number expressed in decimal notation or an integer.
The exponent is an integer number with an optional plus or minus sign. The letter
e separating the mantissa and the exponent can be written in either lowercase or
uppercase. Since the exponent causes the decimal point to “float”, this notation is
said to represent a real number in floating point form.
Example:-0.65e4, 12e-2 1.5e+5
Single Character Constant:-
• A single character constant contains a single character enclosed within a pair of
single quote marks. Example:- ‘5’, ‘X’
• Character constant have integer values known as ASCII value.
Example:- printf(“%d”, ‘a’)
Would print the number 97, the ASCII value of the letter a. the statement
• Since each character constant represents an integer value, it is also possible to
perform arithmetic operations on character.
String constant:-
• A string constant is a sequence of characters enclosed in double
quotes. The characters may be letters, numbers, special characters and
blank space. Example:-”Hello!”, “WEL DONE”
• Remember that a character constant is not equivalent to the single
character string constant. Further, a single character string constant
does not have an equivalent integer value while a character constant
has an integer value. Character strings are often used in programs to
build meaningful programs.
Variables:-
• A variable is a data name that be used to store a data value. Unlike constant
that remain unchanged during the execution of a program, a variable may
take different values at different times during execution.
• A variable name can be chosen by the programmer in a meaningful way so
as to reflect its function or nature in the program.
Examples:- Average, height, Total
• As mentioned earlier, variable names consist of letter, digits, and the
underscore(_) character, subject to the following conditions:
1) They must begin with a letter. Some systems permit inderscore as the first
character.
2) Uppercase and lowercase are significant. That is, variable Total is not the
same as total or TOTAL.
3) It should not be a keyword.
4) White space is not allowed.
Data Types:-
• C language is rich in its data types. Storage representations and
machine instructions to handle constants differ from machine to
machine. the variety of data types available allow the programmer to
select the type appropriate to the need of the applications as well as the
machine.
• ANSI C support three classes of data types:
1) Primary data type
2) Derived data types
3) User-defined data type
All C compilers support five fundamental data types, namely
integer(int), character(char), floating point(float), double-precision
floating point(double),and void.
Integer types:-
• Integers are whole numbers with a range of values supported by a
particular machine. Generally occupy one word of storage, and since
the word sizes of machines vary the size of an integer that can be
stored depends on the computer. If we use a 16 bit word length, the
size of the integer value is limited to the range -32768 to +32767.
• In order to provide some control over the range of numbers and
storage space, C has three classes of integer storage, namely short int,
int and long int, in both signed and unsigned forms. ANSI C defines
these types so that they can be organized from the smallest to the
largest.
• Short int
int
Long int
Floating Point Types:-
• Floating point numbers are stored in 32 bits, with 6digits of precision.
Floating point numbers are defined in C by the keyword float. When
the accuracy provided by a float number is not sufficient, the type
double can be used to define the number.
• A double data type number user 64 bits giving a precision of 14 digits.
These are known as double precision numbers. Remember that double
type represents the same data type that float represents, but with a
greater precision. To extend the precision further, we may use long
double which uses 80 bits.
Float
double
Long double
Void Types:-
• The void types has no values. This is usually used to specify the type
of functions. The type of a function is said to be void when it does not
return any value to the calling function. It can also play the role of a
generic type, meaning that it can represent any of the other standard
types.
Character types:-
• A single character can be defined as a character(char) type data.
Characters are usually stoped in 8 bits of internal storage. The qualifier
signed or unsigned may be explicitly applied to char. While unsigned
char have between 0 and 255, signed chars have values from -128 to
127.
Constant, variables, data types

More Related Content

PPTX
Data types in C language
PPTX
pseudocode and Flowchart
PPTX
NUMBER BASE SYSTEM.pptx
PPTX
Artificial Intelligence(AI).
PPTX
Contant, Variable and Algebraic Expressions
PPTX
Neuro-fuzzy systems
PPTX
Rights of refugees
PPT
Lecture 1 - Lexical Analysis.ppt
Data types in C language
pseudocode and Flowchart
NUMBER BASE SYSTEM.pptx
Artificial Intelligence(AI).
Contant, Variable and Algebraic Expressions
Neuro-fuzzy systems
Rights of refugees
Lecture 1 - Lexical Analysis.ppt

What's hot (20)

PPTX
Data Types and Variables In C Programming
PPTX
data types in C programming
PPT
Variables in C Programming
PPTX
Control statements in c
PPTX
Programming in c Arrays
PPTX
Data types
PPTX
Union in C programming
PPTX
Pointer in c
PPTX
Strings in c++
PPTX
C keywords and identifiers
PPTX
Pointer in C++
PPTX
Pointers in C Programming
PPT
File handling in c
PPT
Strings
PDF
Introduction to c++ ppt 1
PPTX
Functions in c++
PPSX
Files in c++
PDF
Object oriented programming c++
PPTX
Functions in c language
Data Types and Variables In C Programming
data types in C programming
Variables in C Programming
Control statements in c
Programming in c Arrays
Data types
Union in C programming
Pointer in c
Strings in c++
C keywords and identifiers
Pointer in C++
Pointers in C Programming
File handling in c
Strings
Introduction to c++ ppt 1
Functions in c++
Files in c++
Object oriented programming c++
Functions in c language
Ad

Viewers also liked (12)

PPT
Data types and Operators
PPTX
Output in c++ (cout)
PPTX
04 data types & variables
PPTX
Data types and variables
PPS
Data types ,variables,array
PDF
Sdd HSC Summary
PPTX
Software Design and Development
PDF
IPT HSC Summary
PPTX
Variables, Data Types, Operator & Expression in c in detail
PPTX
R Programming: Variables & Data Types
PPT
02. Data Type and Variables
PPT
Variables and Tables
Data types and Operators
Output in c++ (cout)
04 data types & variables
Data types and variables
Data types ,variables,array
Sdd HSC Summary
Software Design and Development
IPT HSC Summary
Variables, Data Types, Operator & Expression in c in detail
R Programming: Variables & Data Types
02. Data Type and Variables
Variables and Tables
Ad

Similar to Constant, variables, data types (20)

PPTX
Introduction to C language programming.pptx
PDF
Constants Variables Datatypes by Mrs. Sowmya Jyothi
PPT
constants, variables and datatypes in C
PPT
CONSTANTS, VARIABLES & DATATYPES IN C
PPTX
Module 1:Introduction
PPTX
Constants variables data_types
PPTX
Structure of c_program_to_input_output
PPT
All C ppt.ppt
PPTX
A Closer Look at Data Types, Variables and Expressions
PPTX
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
PPTX
1173_237_747_Module_2_Part1__Basics_of_C_programming__1_.pptx
PDF
C++ PPT IN NUMERICAL METHOD FOR M.Sc PHYSICS
PPTX
C tokens.pptx
PPT
5-Lec - Datatypes.ppt
PPTX
Lecture 2
PPT
Unit 1 Built in Data types in C language.ppt
PPSX
Programming in c
DOCX
C programming tutorial
PPT
C presentation book
PPTX
LESSON1-C_programming (1).GRADE 8 LESSONpptx
Introduction to C language programming.pptx
Constants Variables Datatypes by Mrs. Sowmya Jyothi
constants, variables and datatypes in C
CONSTANTS, VARIABLES & DATATYPES IN C
Module 1:Introduction
Constants variables data_types
Structure of c_program_to_input_output
All C ppt.ppt
A Closer Look at Data Types, Variables and Expressions
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
1173_237_747_Module_2_Part1__Basics_of_C_programming__1_.pptx
C++ PPT IN NUMERICAL METHOD FOR M.Sc PHYSICS
C tokens.pptx
5-Lec - Datatypes.ppt
Lecture 2
Unit 1 Built in Data types in C language.ppt
Programming in c
C programming tutorial
C presentation book
LESSON1-C_programming (1).GRADE 8 LESSONpptx

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Complications of Minimal Access Surgery at WLH
Weekly quiz Compilation Jan -July 25.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Yogi Goddess Pres Conference Studio Updates
Anesthesia in Laparoscopic Surgery in India
Microbial disease of the cardiovascular and lymphatic systems
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial diseases, their pathogenesis and prophylaxis
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
Final Presentation General Medicine 03-08-2024.pptx
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
school management -TNTEU- B.Ed., Semester II Unit 1.pptx

Constant, variables, data types

  • 2. Constant:- • Constant is C refer to fixed value that do not change during the execution of a program. C supports several types of constant. 1) Integer constants 2) Real constants 3) Single character constant 4) String constant
  • 3. Integer constant:- • An integer constant refers to a sequence of digits. There are three types of integer ,namely ,decimal integer ,octal integer ,hexadecimal integer. • Decimal integer consist of a set of digit, 0 through 9, preceded by an optional – or + sign. Examples:- 123,-321,0,654321,+78 • Embedded spaces, commas, and non-digit character are not permitted between digits. For examples:-15750,20000,$1000 • A sequence of digits preceded by 0x or oX is considered as hexadecimal integer. They may also include alphabets A through f. the letter A through F represent the numbers 10 through 15. Examples:-0X2 ,0x9F ,0Xbcd ,0x • We rarely use octal and hexadecimal numbers in programing. • The largest integer value that can be stored in machine-dependent. It is 32767 on 16-bit machines and 2,147,483,647 on 32 bit- machines.
  • 4. Real constants:- • Integer number are inadequate quantities that vary continuously, such as distances, heights, temperature, prices, and so on. These quantities are represented by numbers containing fractional parts like 17.548. such numbers are called real constants. • These numbers are shown in decimal notation, having a whole number followed by a decimal point and the fractional part. • A real number may also be expressed in exponential notation. For example, the value 215.65 may be written as 2.165e2 in exponential notation. e2 means multiply by 10*10. • The mantissa is either a real number expressed in decimal notation or an integer. The exponent is an integer number with an optional plus or minus sign. The letter e separating the mantissa and the exponent can be written in either lowercase or uppercase. Since the exponent causes the decimal point to “float”, this notation is said to represent a real number in floating point form. Example:-0.65e4, 12e-2 1.5e+5
  • 5. Single Character Constant:- • A single character constant contains a single character enclosed within a pair of single quote marks. Example:- ‘5’, ‘X’ • Character constant have integer values known as ASCII value. Example:- printf(“%d”, ‘a’) Would print the number 97, the ASCII value of the letter a. the statement • Since each character constant represents an integer value, it is also possible to perform arithmetic operations on character.
  • 6. String constant:- • A string constant is a sequence of characters enclosed in double quotes. The characters may be letters, numbers, special characters and blank space. Example:-”Hello!”, “WEL DONE” • Remember that a character constant is not equivalent to the single character string constant. Further, a single character string constant does not have an equivalent integer value while a character constant has an integer value. Character strings are often used in programs to build meaningful programs.
  • 7. Variables:- • A variable is a data name that be used to store a data value. Unlike constant that remain unchanged during the execution of a program, a variable may take different values at different times during execution. • A variable name can be chosen by the programmer in a meaningful way so as to reflect its function or nature in the program. Examples:- Average, height, Total • As mentioned earlier, variable names consist of letter, digits, and the underscore(_) character, subject to the following conditions: 1) They must begin with a letter. Some systems permit inderscore as the first character. 2) Uppercase and lowercase are significant. That is, variable Total is not the same as total or TOTAL. 3) It should not be a keyword. 4) White space is not allowed.
  • 8. Data Types:- • C language is rich in its data types. Storage representations and machine instructions to handle constants differ from machine to machine. the variety of data types available allow the programmer to select the type appropriate to the need of the applications as well as the machine. • ANSI C support three classes of data types: 1) Primary data type 2) Derived data types 3) User-defined data type All C compilers support five fundamental data types, namely integer(int), character(char), floating point(float), double-precision floating point(double),and void.
  • 9. Integer types:- • Integers are whole numbers with a range of values supported by a particular machine. Generally occupy one word of storage, and since the word sizes of machines vary the size of an integer that can be stored depends on the computer. If we use a 16 bit word length, the size of the integer value is limited to the range -32768 to +32767. • In order to provide some control over the range of numbers and storage space, C has three classes of integer storage, namely short int, int and long int, in both signed and unsigned forms. ANSI C defines these types so that they can be organized from the smallest to the largest. • Short int int Long int
  • 10. Floating Point Types:- • Floating point numbers are stored in 32 bits, with 6digits of precision. Floating point numbers are defined in C by the keyword float. When the accuracy provided by a float number is not sufficient, the type double can be used to define the number. • A double data type number user 64 bits giving a precision of 14 digits. These are known as double precision numbers. Remember that double type represents the same data type that float represents, but with a greater precision. To extend the precision further, we may use long double which uses 80 bits. Float double Long double
  • 11. Void Types:- • The void types has no values. This is usually used to specify the type of functions. The type of a function is said to be void when it does not return any value to the calling function. It can also play the role of a generic type, meaning that it can represent any of the other standard types.
  • 12. Character types:- • A single character can be defined as a character(char) type data. Characters are usually stoped in 8 bits of internal storage. The qualifier signed or unsigned may be explicitly applied to char. While unsigned char have between 0 and 255, signed chars have values from -128 to 127.