SlideShare a Scribd company logo
C Programming Language Step by Step Part 3
Type Description
char Typically a single octet(one byte). This is an integer
type.
int The most natural size of integer for the machine.
float A single-precision floating point value.
double A double-precision floating point value.
void Represents the absence of type.
Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -
2,147,483,648 to
2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to
4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to
2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
Integer Types
#include <stdio.h>
#include <limits.h>
int main()
{
printf("Storage size for int : %d n", sizeof(int));
return 0;
}
Floating-Point Types
Type Storage size Value range Precision
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to
1.7E+308
15 decimal
places
long double 10 byte 3.4E-4932 to
1.1E+4932
19 decimal
places
#include <stdio.h>
#include <float.h>
int main()
{
printf("Storage size for float : %d n", sizeof(float));
printf("Minimum float positive value: %En", FLT_MIN );
printf("Maximum float positive value: %En", FLT_MAX );
printf("Precision value: %dn", FLT_DIG );
return 0;
}
Variable Definition in C:
type variable_list;
int i, j, k;
char c, ch;
float f, salary;
double d,e ;
int i ;
char c ;
float f ;
double d;
Variables can be initialized (assigned an initial value) in their declaration.
The initializer consists of an equal sign followed by a constant expression as follows:
int d = 3, f = 5; // definition and initializing d and f.
byte z = 22; // definition and initializes z.
char x = 'x'; // the variable x has the value 'x'.
#include <stdio.h>
int main ()
{
/* variable definition: */
int a, b;
int c;
float f;
/* actual initialization */
a = 10;
b = 20;
c = a + b;
printf("value of c : %d n", c);
f = 70.0/3.0;
printf("value of f : %f n", f);
return 0;
}
This is a Sample Example Of variable definition and initialization
Constants and Literals
The constants refer to fixed values that the program may not alter during its
execution. These fixed values are also called literals.
The constants are treated just like regular variables except that their values
cannot be modified after their definition.
constants
integer constant floating constant character constant
Following are other examples of various type of Integer literals:
85 /* decimal */
0213 /* octal */
0x4b /* hexadecimal */
30 /* int */
30u /* unsigned int */
30l /* long */
30ul /* unsigned long */
Here are some examples of floating-point literals:
3.14159 /* Legal */
510E /* Illegal: incomplete exponent */
210f /* Illegal: no decimal or exponent */
Defining Constants
There are two simple ways in C to define constants:
1. Using #define preprocessor.
2. Using const keyword.
#include <stdio.h>
#define LENGTH 10
#define WIDTH 5
#define NEWLINE 'n'
int main()
{
int area;
area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);
return 0;
}
Example
of
#define
Or
The #define Preprocessor
The const Keyword
const data_type variable_name = value;
#include <stdio.h>
int main()
{
const int LENGTH = 10;
const int WIDTH = 5;
const char NEWLINE = 'n';
int area;
area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);
return 0;
}
Ad

Recommended

Pointers
Pointers
PreethyJemima
 
Introduction to c programming
Introduction to c programming
SaranyaK68
 
Assignment c programming
Assignment c programming
Icaii Infotech
 
Strings
Strings
Saranya saran
 
C Programming Assignment
C Programming Assignment
Vijayananda Mohire
 
Basic of c &c++
Basic of c &c++
guptkashish
 
Lecture no 1
Lecture no 1
hasi071
 
Lecture 17 - Strings
Lecture 17 - Strings
Md. Imran Hossain Showrov
 
JAVA Literals
JAVA Literals
ASHUTOSH TRIVEDI
 
data types in C-Sharp (C#)
data types in C-Sharp (C#)
Abid Kohistani
 
T02 a firstcprogram
T02 a firstcprogram
princepavan
 
Lập trình C
Lập trình C
Viet NguyenHoang
 
Lập trình C
Lập trình C
Viet NguyenHoang
 
String C Programming
String C Programming
Prionto Abdullah
 
Basic concept of c++
Basic concept of c++
shashikant pabari
 
Array, string and pointer
Array, string and pointer
Nishant Munjal
 
Csharp4 operators and_casts
Csharp4 operators and_casts
Abed Bukhari
 
Lecture 6
Lecture 6
Mohammed Saleh
 
Lecture 18 - Pointers
Lecture 18 - Pointers
Md. Imran Hossain Showrov
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
Md. Imran Hossain Showrov
 
Arrays cpu2
Arrays cpu2
Krunal Koladiya
 
C programming(part 3)
C programming(part 3)
Dr. SURBHI SAROHA
 
Programming in C (part 2)
Programming in C (part 2)
Dr. SURBHI SAROHA
 
Unit 8. Pointers
Unit 8. Pointers
Ashim Lamichhane
 
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
C programming Tutorial Session 4
C programming Tutorial Session 4
Muhammad Ehtisham Siddiqui
 
C Programming Unit-3
C Programming Unit-3
Vikram Nandini
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 

More Related Content

What's hot (20)

JAVA Literals
JAVA Literals
ASHUTOSH TRIVEDI
 
data types in C-Sharp (C#)
data types in C-Sharp (C#)
Abid Kohistani
 
T02 a firstcprogram
T02 a firstcprogram
princepavan
 
Lập trình C
Lập trình C
Viet NguyenHoang
 
Lập trình C
Lập trình C
Viet NguyenHoang
 
String C Programming
String C Programming
Prionto Abdullah
 
Basic concept of c++
Basic concept of c++
shashikant pabari
 
Array, string and pointer
Array, string and pointer
Nishant Munjal
 
Csharp4 operators and_casts
Csharp4 operators and_casts
Abed Bukhari
 
Lecture 6
Lecture 6
Mohammed Saleh
 
Lecture 18 - Pointers
Lecture 18 - Pointers
Md. Imran Hossain Showrov
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
Md. Imran Hossain Showrov
 
Arrays cpu2
Arrays cpu2
Krunal Koladiya
 
C programming(part 3)
C programming(part 3)
Dr. SURBHI SAROHA
 
Programming in C (part 2)
Programming in C (part 2)
Dr. SURBHI SAROHA
 
Unit 8. Pointers
Unit 8. Pointers
Ashim Lamichhane
 
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
C programming Tutorial Session 4
C programming Tutorial Session 4
Muhammad Ehtisham Siddiqui
 
C Programming Unit-3
C Programming Unit-3
Vikram Nandini
 

Viewers also liked (20)

C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
Rumman Ansari
 
Tuncel tunçsds
Tuncel tunçsds
pashasoner
 
Các kỹ năng của thế kỷ 21
Các kỹ năng của thế kỷ 21
đại học sư phạm
 
Work. Life. Leader. A Manifesto (Dec. 2016)
Work. Life. Leader. A Manifesto (Dec. 2016)
Julie Cohen
 
Why I Love Winter
Why I Love Winter
AAHSPresentation
 
запобігання дитячому травматизму від внп
запобігання дитячому травматизму від внп
Poltava municipal lyceum #1
 
Convenzione cpsp apsp-dogane
Convenzione cpsp apsp-dogane
Claudia Bertanza
 
toroidwork07-12-2012
toroidwork07-12-2012
Martin Jones
 
160523_SIN2647_Rockley_SalesBrochure_IlloBook_FA
160523_SIN2647_Rockley_SalesBrochure_IlloBook_FA
Hilary Simmons
 
Presentazione dltm assegni
Presentazione dltm assegni
Claudia Bertanza
 
Biografía de Lali Espósito
Biografía de Lali Espósito
Maria Isolina Hernández Rodriguez
 
Practica
Practica
karibohorquez
 
SMARTWaste Brochure 2015
SMARTWaste Brochure 2015
Stuart Blofeld
 
Denunce cittadini
Denunce cittadini
Claudia Bertanza
 
план виховної роботи на і семестр 2014 2015 вовченко о.м.
план виховної роботи на і семестр 2014 2015 вовченко о.м.
Poltava municipal lyceum #1
 
Dossier liberiamo-gli-animali-dai-circhi
Dossier liberiamo-gli-animali-dai-circhi
Claudia Bertanza
 
життя поруч з віл інфекцією та снідом
життя поруч з віл інфекцією та снідом
Poltava municipal lyceum #1
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
Rumman Ansari
 
Tuncel tunçsds
Tuncel tunçsds
pashasoner
 
Work. Life. Leader. A Manifesto (Dec. 2016)
Work. Life. Leader. A Manifesto (Dec. 2016)
Julie Cohen
 
запобігання дитячому травматизму від внп
запобігання дитячому травматизму від внп
Poltava municipal lyceum #1
 
Convenzione cpsp apsp-dogane
Convenzione cpsp apsp-dogane
Claudia Bertanza
 
toroidwork07-12-2012
toroidwork07-12-2012
Martin Jones
 
160523_SIN2647_Rockley_SalesBrochure_IlloBook_FA
160523_SIN2647_Rockley_SalesBrochure_IlloBook_FA
Hilary Simmons
 
Presentazione dltm assegni
Presentazione dltm assegni
Claudia Bertanza
 
SMARTWaste Brochure 2015
SMARTWaste Brochure 2015
Stuart Blofeld
 
план виховної роботи на і семестр 2014 2015 вовченко о.м.
план виховної роботи на і семестр 2014 2015 вовченко о.м.
Poltava municipal lyceum #1
 
Dossier liberiamo-gli-animali-dai-circhi
Dossier liberiamo-gli-animali-dai-circhi
Claudia Bertanza
 
життя поруч з віл інфекцією та снідом
життя поруч з віл інфекцією та снідом
Poltava municipal lyceum #1
 
Ad

Similar to C Programming Language Step by Step Part 3 (20)

Fundamentals of Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
C language basics
C language basics
Nikshithas R
 
Data type in c
Data type in c
thirumalaikumar3
 
Introduction to c programming
Introduction to c programming
SaranyaK68
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
rohassanie
 
What are variables and keywords in c++
What are variables and keywords in c++
Abdul Hafeez
 
Lesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
Intro C# Book
 
Cpprm
Cpprm
Shawne Lee
 
Structured Programming with C - Data Types.ppt
Structured Programming with C - Data Types.ppt
EmmanuelGathu
 
2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming Language
SURAJ KUMAR
 
Data type
Data type
Isha Aggarwal
 
C Sharp Jn (1)
C Sharp Jn (1)
jahanullah
 
C Sharp Nagina (1)
C Sharp Nagina (1)
guest58c84c
 
Data types
Data types
SandhuSaab12
 
Data type2 c
Data type2 c
thirumalaikumar3
 
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
Muhammad Khubaib Awan
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
Fundamentals of Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
Introduction to c programming
Introduction to c programming
SaranyaK68
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
rohassanie
 
What are variables and keywords in c++
What are variables and keywords in c++
Abdul Hafeez
 
Lesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
Intro C# Book
 
Structured Programming with C - Data Types.ppt
Structured Programming with C - Data Types.ppt
EmmanuelGathu
 
2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming Language
SURAJ KUMAR
 
C Sharp Jn (1)
C Sharp Jn (1)
jahanullah
 
C Sharp Nagina (1)
C Sharp Nagina (1)
guest58c84c
 
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
Muhammad Khubaib Awan
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
Ad

More from Rumman Ansari (20)

Sql tutorial
Sql tutorial
Rumman Ansari
 
C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Java Questions and Answers
Rumman Ansari
 
servlet programming
servlet programming
Rumman Ansari
 
C program to write c program without using main function
C program to write c program without using main function
Rumman Ansari
 
Steps for c program execution
Steps for c program execution
Rumman Ansari
 
Pointer in c program
Pointer in c program
Rumman Ansari
 
My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
How c program execute in c program
How c program execute in c program
Rumman Ansari
 
What is token c programming
What is token c programming
Rumman Ansari
 
What is identifier c programming
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 11
C Programming Language Part 11
Rumman Ansari
 
C Programming Language Part 9
C Programming Language Part 9
Rumman Ansari
 
C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
C Programming Language Part 6
C Programming Language Part 6
Rumman Ansari
 
C Programming Language Part 5
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Part 4
C Programming Language Part 4
Rumman Ansari
 
C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Java Questions and Answers
Rumman Ansari
 
C program to write c program without using main function
C program to write c program without using main function
Rumman Ansari
 
Steps for c program execution
Steps for c program execution
Rumman Ansari
 
Pointer in c program
Pointer in c program
Rumman Ansari
 
My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
How c program execute in c program
How c program execute in c program
Rumman Ansari
 
What is token c programming
What is token c programming
Rumman Ansari
 
What is identifier c programming
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 11
C Programming Language Part 11
Rumman Ansari
 
C Programming Language Part 9
C Programming Language Part 9
Rumman Ansari
 
C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
C Programming Language Part 6
C Programming Language Part 6
Rumman Ansari
 
C Programming Language Part 5
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Part 4
C Programming Language Part 4
Rumman Ansari
 

Recently uploaded (20)

IntroSlides-June-GDG-Cloud-Munich community [email protected]
IntroSlides-June-GDG-Cloud-Munich community [email protected]
Luiz Carneiro
 
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ijab2
 
Stay Safe Women Security Android App Project Report.pdf
Stay Safe Women Security Android App Project Report.pdf
Kamal Acharya
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Cadastral Maps
Cadastral Maps
Google
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
grade 9 science q1 quiz.pptx science quiz
grade 9 science q1 quiz.pptx science quiz
norfapangolima
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
IJCNCJournal
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
ElysiumPro Company Profile 2025-2026.pdf
ElysiumPro Company Profile 2025-2026.pdf
info751436
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
ravicivil
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ijab2
 
Stay Safe Women Security Android App Project Report.pdf
Stay Safe Women Security Android App Project Report.pdf
Kamal Acharya
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Cadastral Maps
Cadastral Maps
Google
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
grade 9 science q1 quiz.pptx science quiz
grade 9 science q1 quiz.pptx science quiz
norfapangolima
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...
IJCNCJournal
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
ElysiumPro Company Profile 2025-2026.pdf
ElysiumPro Company Profile 2025-2026.pdf
info751436
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
ravicivil
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 

C Programming Language Step by Step Part 3

  • 2. Type Description char Typically a single octet(one byte). This is an integer type. int The most natural size of integer for the machine. float A single-precision floating point value. double A double-precision floating point value. void Represents the absence of type.
  • 3. Type Storage size Value range char 1 byte -128 to 127 or 0 to 255 unsigned char 1 byte 0 to 255 signed char 1 byte -128 to 127 int 2 or 4 bytes -32,768 to 32,767 or - 2,147,483,648 to 2,147,483,647 unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295 short 2 bytes -32,768 to 32,767 unsigned short 2 bytes 0 to 65,535 long 4 bytes -2,147,483,648 to 2,147,483,647 unsigned long 4 bytes 0 to 4,294,967,295 Integer Types
  • 4. #include <stdio.h> #include <limits.h> int main() { printf("Storage size for int : %d n", sizeof(int)); return 0; }
  • 5. Floating-Point Types Type Storage size Value range Precision float 4 byte 1.2E-38 to 3.4E+38 6 decimal places double 8 byte 2.3E-308 to 1.7E+308 15 decimal places long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places
  • 6. #include <stdio.h> #include <float.h> int main() { printf("Storage size for float : %d n", sizeof(float)); printf("Minimum float positive value: %En", FLT_MIN ); printf("Maximum float positive value: %En", FLT_MAX ); printf("Precision value: %dn", FLT_DIG ); return 0; }
  • 7. Variable Definition in C: type variable_list; int i, j, k; char c, ch; float f, salary; double d,e ; int i ; char c ; float f ; double d; Variables can be initialized (assigned an initial value) in their declaration. The initializer consists of an equal sign followed by a constant expression as follows: int d = 3, f = 5; // definition and initializing d and f. byte z = 22; // definition and initializes z. char x = 'x'; // the variable x has the value 'x'.
  • 8. #include <stdio.h> int main () { /* variable definition: */ int a, b; int c; float f; /* actual initialization */ a = 10; b = 20; c = a + b; printf("value of c : %d n", c); f = 70.0/3.0; printf("value of f : %f n", f); return 0; } This is a Sample Example Of variable definition and initialization
  • 9. Constants and Literals The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. The constants are treated just like regular variables except that their values cannot be modified after their definition. constants integer constant floating constant character constant
  • 10. Following are other examples of various type of Integer literals: 85 /* decimal */ 0213 /* octal */ 0x4b /* hexadecimal */ 30 /* int */ 30u /* unsigned int */ 30l /* long */ 30ul /* unsigned long */ Here are some examples of floating-point literals: 3.14159 /* Legal */ 510E /* Illegal: incomplete exponent */ 210f /* Illegal: no decimal or exponent */
  • 11. Defining Constants There are two simple ways in C to define constants: 1. Using #define preprocessor. 2. Using const keyword. #include <stdio.h> #define LENGTH 10 #define WIDTH 5 #define NEWLINE 'n' int main() { int area; area = LENGTH * WIDTH; printf("value of area : %d", area); printf("%c", NEWLINE); return 0; } Example of #define Or The #define Preprocessor
  • 12. The const Keyword const data_type variable_name = value; #include <stdio.h> int main() { const int LENGTH = 10; const int WIDTH = 5; const char NEWLINE = 'n'; int area; area = LENGTH * WIDTH; printf("value of area : %d", area); printf("%c", NEWLINE); return 0; }