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;
}

More Related Content

PPTX
Pointers
PPTX
Introduction to c programming
DOC
Assignment c programming
PPTX
Strings
PDF
C Programming Assignment
PPT
Basic of c &c++
PPTX
Lecture no 1
PPT
Lecture 17 - Strings
Pointers
Introduction to c programming
Assignment c programming
Strings
C Programming Assignment
Basic of c &c++
Lecture no 1
Lecture 17 - Strings

What's hot (20)

PPTX
JAVA Literals
PPTX
data types in C-Sharp (C#)
PPS
T02 a firstcprogram
PPT
Lập trình C
PPT
Lập trình C
PPTX
String C Programming
PPT
Basic concept of c++
PPTX
Array, string and pointer
PPT
Csharp4 operators and_casts
PPT
Lecture 6
PPT
Lecture 18 - Pointers
PDF
[ITP - Lecture 04] Variables and Constants in C/C++
PPT
Lecture 6- Intorduction to C Programming
PPT
Arrays cpu2
PPTX
C programming(part 3)
PPTX
Programming in C (part 2)
PPTX
Unit 8. Pointers
PDF
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
PPTX
C programming Tutorial Session 4
PPTX
C Programming Unit-3
JAVA Literals
data types in C-Sharp (C#)
T02 a firstcprogram
Lập trình C
Lập trình C
String C Programming
Basic concept of c++
Array, string and pointer
Csharp4 operators and_casts
Lecture 6
Lecture 18 - Pointers
[ITP - Lecture 04] Variables and Constants in C/C++
Lecture 6- Intorduction to C Programming
Arrays cpu2
C programming(part 3)
Programming in C (part 2)
Unit 8. Pointers
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
C programming Tutorial Session 4
C Programming Unit-3
Ad

Viewers also liked (20)

PPTX
C Programming Language Step by Step Part 5
PPTX
C Programming Language Part 8
PPTX
C Programming Language Step by Step Part 1
PPTX
Tuncel tunçsds
DOCX
Các kỹ năng của thế kỷ 21
PDF
Work. Life. Leader. A Manifesto (Dec. 2016)
PDF
Why I Love Winter
PPT
запобігання дитячому травматизму від внп
DOCX
Convenzione cpsp apsp-dogane
PDF
toroidwork07-12-2012
PDF
160523_SIN2647_Rockley_SalesBrochure_IlloBook_FA
PPT
Job analysis
PDF
Presentazione dltm assegni
ODP
Biografía de Lali Espósito
PPTX
Practica
PDF
SMARTWaste Brochure 2015
PDF
Denunce cittadini
DOC
план виховної роботи на і семестр 2014 2015 вовченко о.м.
PDF
Dossier liberiamo-gli-animali-dai-circhi
PPT
життя поруч з віл інфекцією та снідом
C Programming Language Step by Step Part 5
C Programming Language Part 8
C Programming Language Step by Step Part 1
Tuncel tunçsds
Các kỹ năng của thế kỷ 21
Work. Life. Leader. A Manifesto (Dec. 2016)
Why I Love Winter
запобігання дитячому травматизму від внп
Convenzione cpsp apsp-dogane
toroidwork07-12-2012
160523_SIN2647_Rockley_SalesBrochure_IlloBook_FA
Job analysis
Presentazione dltm assegni
Biografía de Lali Espósito
Practica
SMARTWaste Brochure 2015
Denunce cittadini
план виховної роботи на і семестр 2014 2015 вовченко о.м.
Dossier liberiamo-gli-animali-dai-circhi
життя поруч з віл інфекцією та снідом
Ad

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

PPTX
COM1407: Variables and Data Types
DOCX
PPTX
A Closer Look at Data Types, Variables and Expressions
PPTX
Variable declaration
PPTX
Introduction to C language programming.pptx
PPTX
Constant, variables, data types
PDF
Constants Variables Datatypes by Mrs. Sowmya Jyothi
PPTX
Constants variables data_types
PPTX
Datatypes
PPTX
Basic of Structered Programming in C psd
PDF
C Tutorial
PPTX
Lecture 2
PPT
Structured Programming with C - Data Types.ppt
PPT
Mesics lecture 3 c – constants and variables
PPT
C language Unit 2 Slides, UPTU C language
PDF
C SLIDES PREPARED BY M V B REDDY
PPTX
PPTX
C language
PPT
Unit 1 Built in Data types in C language.ppt
PPT
Data Types in C
COM1407: Variables and Data Types
A Closer Look at Data Types, Variables and Expressions
Variable declaration
Introduction to C language programming.pptx
Constant, variables, data types
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants variables data_types
Datatypes
Basic of Structered Programming in C psd
C Tutorial
Lecture 2
Structured Programming with C - Data Types.ppt
Mesics lecture 3 c – constants and variables
C language Unit 2 Slides, UPTU C language
C SLIDES PREPARED BY M V B REDDY
C language
Unit 1 Built in Data types in C language.ppt
Data Types in C

More from Rumman Ansari (20)

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

Recently uploaded (20)

PPTX
web development for engineering and engineering
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
PPT on Performance Review to get promotions
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Sustainable Sites - Green Building Construction
PDF
Digital Logic Computer Design lecture notes
PPT
Project quality management in manufacturing
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Lecture Notes Electrical Wiring System Components
DOCX
573137875-Attendance-Management-System-original
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
web development for engineering and engineering
bas. eng. economics group 4 presentation 1.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT on Performance Review to get promotions
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Sustainable Sites - Green Building Construction
Digital Logic Computer Design lecture notes
Project quality management in manufacturing
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Lecture Notes Electrical Wiring System Components
573137875-Attendance-Management-System-original
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf

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; }