SlideShare a Scribd company logo
1 of 23
DATA TYPES IN C
PROGRAMMING
• Created by:-
• Ansh Srivastava
Introduction:-
• The C programming is a general purpose programming language
that is extremely popular, simple, and flexible to use it is a
structured programming language that is machine-independent and
extensively used to write various applications, Operating Systems
like Windows, and many other complex programs like Oracle
database, Git, Python interpreter, and more.
• It is said that ‘C’ is a god’s programming language. One can say, C is
a base for the programming. If you know ‘C,’ you can easily grasp
the knowledge of the other programming languages that uses the
concept of ‘C’
• It is essential to have a background in computer memory
mechanisms because it is an important aspect when dealing with
the C programming language.
What is C ?
• C is a programming language developed at AT&T’s
Bell Laboratories of USA in 1972. it was designed
and written by a man named Dennis Ritchie. In
the last seventies, C began to replace the more
familiar languages of that time like PL/I, ALGOL
etc. no one pushed C. it was not made the
“official” Bell Labs language. Thus, without any
advertisement, C’s that so many programmers
preferred C to older language like FORTRAN or
PL/I, or the newer ones like Pascal and APL. But
that’s what happened.
ABOUT “C”
o C is a structured programming language
o C supports functions that enables easy maintainability of code, by
breaking large file into smaller modules
o Comments in C provides easy readability
o C is a powerful language .
o C programs built from :-
• Variables and type declarations
• Functions
• Statements
• Expressions
C Programming Language
• Variables
• Flow control
• Statement
• Expressions
• Operators
• Functions
• C compiler
• Output
Structure Of “C” Programs
Before going and reading the structure of C
programs we need to have a basic knowledge of
the following:
1. C’s Character Set
2. C’s Keywords
3. The General Structure of a “C”Program
4. How To End A Statement
5. Free Format Language
6. Header Files & Library Functions
C’s Character Set
C does not use every character set and key found
on modern computers.The only characters that C-
Language uses for its programs are as follows;
 A-Z all alphabets
a-z all alphabets
0-9
# % & ! _ {} [] () $$$$$ &&&&
Space . , ; : ’ $ ”
+ - / * =
The Keywords
 “Keywords” are words that have special
meaning to the C compiler.
 Their meaning cannot be changed at any
instance.
 Serve as basic building blocks for program
statements.
 All keywords are written in only lowercase.
Basic Structure Of “C” Programs
# include<stdio.h>
# include<conio.h>
Void main()
{
--other statements
}
Header Files
Entry Point Of
Program
Indicates Starting
of Program
Header files
• The files that are specified in the include
section is called as Header File.
• These are precompiled files that has some
functions defined in them.
• We can call those functions in our program by
supplying parameters.
• Header file is given an extension .h .
• C Source file is given an extension .c .
Main function
• This is the "Entry Point" of a program.
• When a file is executed, the start point is the
main function.
• From main function the flow goes as per the
programmers choice .
• There may or may not be other functions
written by user in a program.
• Main function is compulsory for any C
program.
Running a 'C' Program
• Type a program.
• Save it.
• Compile the program - This will generate an
.exe file (executable)
• Run the program (Actually the exe created
out of compilation will run and not the .c file)
• In different compiler we have different option
for compiling and running.
"C" language TOKENS
 The smallest individual units in a C program are known as tokens. In
a C source program, the basic element recognized by the compiler
is the "token." A token is source-program text that the compiler
does not break down into component elements
 C has 6 different types of tokens viz.
• Keywords [e.g-. float, int, while]
• Identifiers [ e.g main, amount]
• Constant [ e.g -25.6, 100]
• Strings [e.g “SMIT”, “year”]
• Special Symbols. [e.g. {, }, [, ] ]
• Operators [ e.g. +, -, * ]
 C – program are written using these tokens and the general syntax.
Keywords in Ansi “C”
auto double register switch
break else return typedef
case enum short union
char etern signed unsigned
const float sizeof void
continue for static volatile
default goto struct while
do if int long
The Identifiers
• They are programmer-chosen names to represent parts
of the program: variables, functions, etc.
• Cannot use C keywords as identifiers.
• Must begin with alpha character or _, followed by
alpha, numeric, or _
• Upper- and lower-case characters are important (case
sensitive)
• Must consist of only letters, digits or underscore (_)
• Only first 31 characters are significant.
• Must NOT contain spaces ( ).
Constants
• Constants is C are the fixed values that do not
change during the execution of a program.
CONSTANTS
Numeric Constants Character Constants
Integer
Constants Real
Constants
Single
Character
Constants
String
Constants
Constants Examples
Integer Constants
- Refers to sequence of digits such as decimal integer, octal integer
and hexadecimal integer.
- Some of the examples are 112, 0551, 56579u, 0X2 etc.
Real Constants
- The floating point constants such as 0.0083, - 0.78, +67.89 etc.
Single Character Constants
- A single char const contains a single character enclosed within pair of
single quotes [ '' ]. For example, '8', 'a', " etc.
String Constants
- A string constant is a sequence of characters enclosed in double
quotes [ " " ]; For example, "02 1 1", "Stack Overflow" etc.
DECLARATIONS
 Constants and variables must be declared before they can
be used.
 A constant declaration specifies the type, the name and the
value of the constant any attempt to alter the value of a
variable defined
 as constant results in an error message by the compiler
 A variable declaration specifies the type, the name and
possibly the initial value of the variable
 When you declare a constant or a variable, the compiler:
 Reserves a memory location in which to store the value of
the constant or variable.
 Associates the name of the constant or variable with the
memory location.
What Are Variables in C?
• A Variable is a data name that is used to store any data
value.
• Variables are used to store values that can be changed
during the program execution.
• Variables in C have the same meaning as variables in
algebra. That is, they represent some unknown, or
variable, value.
x = a + b
z + 2 = 3(y - 5)
• Remember that variables in algebra are represented by
a single alphabetic character.
Naming Variables
 Variables in C may be given representations containing
multiple characters. But there are rules for these
representations.
 Variable names in C :
 May only consist of letters, digits, and underscores
 May be as long as you like, but only the first 31 characters
are significant.
 May not begin with a number
 May not be a C reserved word (keyword)
 Should start with a letter or an underscore(_)
 Can contain letters, numbers or underscore.
 No other special characters are allowed including space.
Data types in 'ansi c’
• There are three classes of data types here::
• Primitive data types
- int, float, double, char
• Aggregate OR derived data types
- Arrays come under this category
- Arrays can contain collection of int or float or char
or double data
• User defined data types
- Structures and enum fall under this category.
Data Types – different attributes
Type Size Representation Minimum range Maximum range
Char, signed char 8 bits ASCII -128 127
Unsigned char bool 8 bits ASCII -327680 255
Short, signed short 16 bits 2’S complement 0 32767
Unsigned short 16 bits Binary -32768 65535
Int, signed int 16 bits 2’s complement 0 32767
Unsigned int 16 bits Binary -2,147,483,648 65535
Long, signed long 32 bits 2’s complement 0 2,147,483,647
Unsigned long 32 bits Binary 1.175495e-38 4,294,967,295
Float 32 bits IEEE 32-bits 1.175495e-38 3.4028235e+38
Double 32 bits IEEE 32-bits 1.175495e-38 3.4028235e+38
Long double 32 bits IEEE 32-bits 1.175495e-38 3.4028235e+38
Example of “C” Program
/* HELLO.C -- Hello, World*/
#include <studio.h>
Void main()
{
printf(“Hello,worldn”);
Getch();
}

More Related Content

What's hot (20)

Catálogo de PLC S7-200 SMART
Catálogo de PLC S7-200 SMART Catálogo de PLC S7-200 SMART
Catálogo de PLC S7-200 SMART
 
EEE 1102
EEE 1102EEE 1102
EEE 1102
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
Character set in c
Character set in cCharacter set in c
Character set in c
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
 
Ins and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingIns and Outs of GPIO Programming
Ins and Outs of GPIO Programming
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Module 00 Bitwise Operators in C
Module 00 Bitwise Operators in CModule 00 Bitwise Operators in C
Module 00 Bitwise Operators in C
 
Programmable logic controller(plc)
Programmable logic controller(plc)Programmable logic controller(plc)
Programmable logic controller(plc)
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 
History of c
History of cHistory of c
History of c
 
Control statements and functions in c
Control statements and functions in cControl statements and functions in c
Control statements and functions in c
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr Microcontrollers
 
C presentation
C presentationC presentation
C presentation
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Vlsi technology-dinesh
Vlsi technology-dineshVlsi technology-dinesh
Vlsi technology-dinesh
 
Embedded Hardware Design.pptx
Embedded Hardware Design.pptxEmbedded Hardware Design.pptx
Embedded Hardware Design.pptx
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
AUToSAR introduction
AUToSAR introductionAUToSAR introduction
AUToSAR introduction
 

Similar to C PROGRAMMING LANGUAGE.pptx (20)

C language ppt
C language pptC language ppt
C language ppt
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
Aniket tore
Aniket toreAniket tore
Aniket tore
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
C introduction
C introductionC introduction
C introduction
 
SPC Unit 2
SPC Unit 2SPC Unit 2
SPC Unit 2
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
C presentation book
C presentation bookC presentation book
C presentation book
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
Basics of C
Basics of CBasics of C
Basics of C
 

Recently uploaded

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 

Recently uploaded (20)

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 

C PROGRAMMING LANGUAGE.pptx

  • 1. DATA TYPES IN C PROGRAMMING • Created by:- • Ansh Srivastava
  • 2. Introduction:- • The C programming is a general purpose programming language that is extremely popular, simple, and flexible to use it is a structured programming language that is machine-independent and extensively used to write various applications, Operating Systems like Windows, and many other complex programs like Oracle database, Git, Python interpreter, and more. • It is said that ‘C’ is a god’s programming language. One can say, C is a base for the programming. If you know ‘C,’ you can easily grasp the knowledge of the other programming languages that uses the concept of ‘C’ • It is essential to have a background in computer memory mechanisms because it is an important aspect when dealing with the C programming language.
  • 3. What is C ? • C is a programming language developed at AT&T’s Bell Laboratories of USA in 1972. it was designed and written by a man named Dennis Ritchie. In the last seventies, C began to replace the more familiar languages of that time like PL/I, ALGOL etc. no one pushed C. it was not made the “official” Bell Labs language. Thus, without any advertisement, C’s that so many programmers preferred C to older language like FORTRAN or PL/I, or the newer ones like Pascal and APL. But that’s what happened.
  • 4. ABOUT “C” o C is a structured programming language o C supports functions that enables easy maintainability of code, by breaking large file into smaller modules o Comments in C provides easy readability o C is a powerful language . o C programs built from :- • Variables and type declarations • Functions • Statements • Expressions
  • 5. C Programming Language • Variables • Flow control • Statement • Expressions • Operators • Functions • C compiler • Output
  • 6. Structure Of “C” Programs Before going and reading the structure of C programs we need to have a basic knowledge of the following: 1. C’s Character Set 2. C’s Keywords 3. The General Structure of a “C”Program 4. How To End A Statement 5. Free Format Language 6. Header Files & Library Functions
  • 7. C’s Character Set C does not use every character set and key found on modern computers.The only characters that C- Language uses for its programs are as follows;  A-Z all alphabets a-z all alphabets 0-9 # % & ! _ {} [] () $$$$$ &&&& Space . , ; : ’ $ ” + - / * =
  • 8. The Keywords  “Keywords” are words that have special meaning to the C compiler.  Their meaning cannot be changed at any instance.  Serve as basic building blocks for program statements.  All keywords are written in only lowercase.
  • 9. Basic Structure Of “C” Programs # include<stdio.h> # include<conio.h> Void main() { --other statements } Header Files Entry Point Of Program Indicates Starting of Program
  • 10. Header files • The files that are specified in the include section is called as Header File. • These are precompiled files that has some functions defined in them. • We can call those functions in our program by supplying parameters. • Header file is given an extension .h . • C Source file is given an extension .c .
  • 11. Main function • This is the "Entry Point" of a program. • When a file is executed, the start point is the main function. • From main function the flow goes as per the programmers choice . • There may or may not be other functions written by user in a program. • Main function is compulsory for any C program.
  • 12. Running a 'C' Program • Type a program. • Save it. • Compile the program - This will generate an .exe file (executable) • Run the program (Actually the exe created out of compilation will run and not the .c file) • In different compiler we have different option for compiling and running.
  • 13. "C" language TOKENS  The smallest individual units in a C program are known as tokens. In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements  C has 6 different types of tokens viz. • Keywords [e.g-. float, int, while] • Identifiers [ e.g main, amount] • Constant [ e.g -25.6, 100] • Strings [e.g “SMIT”, “year”] • Special Symbols. [e.g. {, }, [, ] ] • Operators [ e.g. +, -, * ]  C – program are written using these tokens and the general syntax.
  • 14. Keywords in Ansi “C” auto double register switch break else return typedef case enum short union char etern signed unsigned const float sizeof void continue for static volatile default goto struct while do if int long
  • 15. The Identifiers • They are programmer-chosen names to represent parts of the program: variables, functions, etc. • Cannot use C keywords as identifiers. • Must begin with alpha character or _, followed by alpha, numeric, or _ • Upper- and lower-case characters are important (case sensitive) • Must consist of only letters, digits or underscore (_) • Only first 31 characters are significant. • Must NOT contain spaces ( ).
  • 16. Constants • Constants is C are the fixed values that do not change during the execution of a program. CONSTANTS Numeric Constants Character Constants Integer Constants Real Constants Single Character Constants String Constants
  • 17. Constants Examples Integer Constants - Refers to sequence of digits such as decimal integer, octal integer and hexadecimal integer. - Some of the examples are 112, 0551, 56579u, 0X2 etc. Real Constants - The floating point constants such as 0.0083, - 0.78, +67.89 etc. Single Character Constants - A single char const contains a single character enclosed within pair of single quotes [ '' ]. For example, '8', 'a', " etc. String Constants - A string constant is a sequence of characters enclosed in double quotes [ " " ]; For example, "02 1 1", "Stack Overflow" etc.
  • 18. DECLARATIONS  Constants and variables must be declared before they can be used.  A constant declaration specifies the type, the name and the value of the constant any attempt to alter the value of a variable defined  as constant results in an error message by the compiler  A variable declaration specifies the type, the name and possibly the initial value of the variable  When you declare a constant or a variable, the compiler:  Reserves a memory location in which to store the value of the constant or variable.  Associates the name of the constant or variable with the memory location.
  • 19. What Are Variables in C? • A Variable is a data name that is used to store any data value. • Variables are used to store values that can be changed during the program execution. • Variables in C have the same meaning as variables in algebra. That is, they represent some unknown, or variable, value. x = a + b z + 2 = 3(y - 5) • Remember that variables in algebra are represented by a single alphabetic character.
  • 20. Naming Variables  Variables in C may be given representations containing multiple characters. But there are rules for these representations.  Variable names in C :  May only consist of letters, digits, and underscores  May be as long as you like, but only the first 31 characters are significant.  May not begin with a number  May not be a C reserved word (keyword)  Should start with a letter or an underscore(_)  Can contain letters, numbers or underscore.  No other special characters are allowed including space.
  • 21. Data types in 'ansi c’ • There are three classes of data types here:: • Primitive data types - int, float, double, char • Aggregate OR derived data types - Arrays come under this category - Arrays can contain collection of int or float or char or double data • User defined data types - Structures and enum fall under this category.
  • 22. Data Types – different attributes Type Size Representation Minimum range Maximum range Char, signed char 8 bits ASCII -128 127 Unsigned char bool 8 bits ASCII -327680 255 Short, signed short 16 bits 2’S complement 0 32767 Unsigned short 16 bits Binary -32768 65535 Int, signed int 16 bits 2’s complement 0 32767 Unsigned int 16 bits Binary -2,147,483,648 65535 Long, signed long 32 bits 2’s complement 0 2,147,483,647 Unsigned long 32 bits Binary 1.175495e-38 4,294,967,295 Float 32 bits IEEE 32-bits 1.175495e-38 3.4028235e+38 Double 32 bits IEEE 32-bits 1.175495e-38 3.4028235e+38 Long double 32 bits IEEE 32-bits 1.175495e-38 3.4028235e+38
  • 23. Example of “C” Program /* HELLO.C -- Hello, World*/ #include <studio.h> Void main() { printf(“Hello,worldn”); Getch(); }