SlideShare a Scribd company logo
DATA STRUCTURES – R19 Course Code-A5502
Part -1: Overview of C
Structure of a C program, data types, operators, type conversion,
formatted input/out functions, Control statements.
1. Structure of a C Program
1. Documentations (Documentation Section)
The Documentation section usually contains the collection of comment lines giving the name of
the program, author's or programmer's name and few other details.
Comments:
 Comments are a way of explaining what makes a program.
 The compiler ignores comments
 Comment can be used anywhere in the program to add info about the program or code block
 Used by other users /programmers to understand the code.
The comments are specified as
a) Single line comment
E.g.: // Program to find factorial
b) Multi line comment
DATA STRUCTURES – R19 Course Code-A5502
E.g.: /*
Program Name is – Factorial
Author Name is – Ramesh
Outcome – Understand loop
*/
2. Preprocessor Statements (Link Section)
This instructs the compiler to connect to the various functions from the system library
3. Definition Section
The Definition section describes all the symbolic-constant.
4. Global Declarations (Definition Section)
Used to define those variables that are used globally within the entire program and is used in
more than one function. This section also declares all the user-defined functions.
5. The main() function
All C programs must have a main () which contains two parts:
Declaration part: Used to declare all variables that will be used within the program. In C
Variables must be declared before using in the program statements.
Execution part: At least one statement for execution
 These two parts are declared within the opening and closing curly braces of the
main ().
 The execution of the program begins at the opening brace '{' and ends with the
closing brace '}'.
 All the statements of these two parts need to be terminated with a semi-colon.
6. User Defined Functions
Deals with all user-defined functions that are called from the main ()
User-defined functions are declared and usually defined after the main () function.
Every C program must consist of one or more functions
Every function has one or more statements to perform a task.
Every C program must have function main (), the execution of a C program begins with
this function. It is an entry point for a C Program.
DATA STRUCTURES – R19 Course Code-A5502
2. Data types in C
C language is rich in its data types.
The Data type determines
The type of value a data item can have.
The range of values a data item can take.
The size of data item in memory bytes.
Possible Operations performed on the data.
C- Supports four modifiers for data types
1. signed - For Positive and Negative Value
2. unsigned - For positive only
3. short - size specifier
4. long - size specifier
DATA STRUCTURES – R19 Course Code-A5502
The Primitive/Primary/ Basic data types in C are
1. char: It stores a single character and requires a single byte of memory in almost all compilers.
o C – Language uses ASCII character set.
o Characters are stored in their ASCII codes (American Standard Code for Information
Interchange).
o ASCII Character set uses 128 characters from 0-127. (1 Byte)
o ASCII Value of A -> 65 , a->97 , 0 ->48
2. int: It is used to store integer value. (2 Bytes)
3. float: It is used to store floating point value with single precision. (4 Bytes)
4. double: It is used to store floating point value with double precision. (8 Bytes)
5. void: It has no value. It is used to specify the type of functions. If the function is void then it
will not return any value.
Note: The size of Data type varies from one System to another.
DATA STRUCTURES – R19 Course Code-A5502
The basic data types and their sizes
S.No Data Type Size in Bytes Range
1 char 1 -128 to +127
2 unsigned char 1 0 to 255
3 signed char 1 -128 to +127
4 int 2 -32768 to +32767
5 unsigned int 2 0 to 65535
6 signed int 2 -32768 to +32767
7 short int 2 -32768 to +32767
8 unsigned short int 2 0 to 65535
9 signed short int 2 -32768 to +32767
10 long int 4 -2147483648 to +21474833647
11 unsigned long int 4 0 to 4294967295
12 signed long int 4 -2147483648 to +21474833647
13 float 4 3.4E-38 to 3.4E+38
14 double 8 1.7E-308 to 1.7E+308
15 long double 10 3.4E-4932 to 1.1E+4932
Identifiers in C
 Identifiers are names given to program elements such as variables, arrays, and functions.
 The name of identifier is formed with any sequence of letters (upper and lower case), numerals
and underscore (_). [Alpha numeric characters only]
Rules for forming identifiers
1. Can not include any special characters or punctuation marks except underscore. E.g. @avg,
avg#
2. Key words cannot be used as identifier names. E.g. int for;
3. Identifier must start with a letter or underscore. E.g. _avg , Avg,avg
4. Must not contain white spaces. E.g. AVG CSE
5. Identifiers are case sensitive. E.g. AVG differ from avg
6. Identifier can be of any reasonable length (only first 31 characters are significant). E.g. Average
DATA STRUCTURES – R19 Course Code-A5502
Keywords in C
Keywords are the reserved words and have a specific meaning already defined by the compiler.
Keywords are a sequence of characters.
Key words are the building blocks for writing C programs.
All keywords must be written in lower case.
Keywords cannot be used as identifier names.
The meaning of a keyword cannot be changed.
The list of keywords supported in C are
Variables and Constants in C
Variables: The primary purpose of variables is to store data in memory for later use. Variables value
may change during execution. If you declare a variable in C, that means you are asking to the operating
system for reserve a piece of memory with that variable name.
A variable has
 Name – Any valid identifier name
 Value - The value of specified type
 Address- The memory address where the variable stored.
 Scope – The range of statements or program, the variable is visible.
 Lifetime- How long the variable does exist in memory.
DATA STRUCTURES – R19 Course Code-A5502
Syntax:
type variable_name;
type variable_name1, variable_name2, variable_namen;
int width, height=5; //variable declaration and initialization
char symbol='A'; //char declaration and initialization
unsigned int count;
signed short int age;
float age, area; //variable declaration
double d;
Constants: Constants is the most fundamental and essential part of the C programming language.
Constants in C are the fixed values that are used in a program, and its value remains the same during
the entire execution of the program.
 Constants are used to define fixed values.
 Values of constants can never be changed.
 Constants are also called literals.
 Constants can be any of the data types.
 It is considered best practice to define constants using only upper-case names.
 Keyword const is used to define constants.
 The constants can be integer constants, character constants, float or real constants.
Syntax:
const type constant_name;
E.g: const int MAX=20;
 const float PI=3.142;
 const double SQRT_2=1.414;
 const char GRADE=’A’;
DATA STRUCTURES – R19 Course Code-A5502
3. Type Conversions
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
4. Formatted Input/Output Functions
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
5. Operators in C
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
DATA STRUCTURES – R19 Course Code-A5502
Operator Precedence and Associativity
 Precedence Rule decides the order in which different operators are applied in an
expression.
 Associativity rule decides the order in which multiple occurrences of the same level
precedence operators are applied in an expression.
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Ad

More Related Content

Similar to PART-1 Over View of C language ( engineering) (20)

C material
C materialC material
C material
tarique472
 
Aniket tore
Aniket toreAniket tore
Aniket tore
anikettore1
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
 
UNIT 1 NOTES.docx
UNIT 1 NOTES.docxUNIT 1 NOTES.docx
UNIT 1 NOTES.docx
Revathiparamanathan
 
Unit No 2.pptx Basic s of C Programming
Unit No 2.pptx   Basic s of C ProgrammingUnit No 2.pptx   Basic s of C Programming
Unit No 2.pptx Basic s of C Programming
Vaibhav Parjane
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
C programming
C programmingC programming
C programming
PralhadKhanal1
 
424769021-1-First-C-Program-1-ppt (1).ppt
424769021-1-First-C-Program-1-ppt (1).ppt424769021-1-First-C-Program-1-ppt (1).ppt
424769021-1-First-C-Program-1-ppt (1).ppt
advRajatSharma
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
Muthuselvam RS
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
sachindane
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
amol_chavan
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
sscprep9
 
C Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdfC Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdf
poongothai11
 
The New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of theThe New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of the
shubhamgupta7133
 
Cnotes
CnotesCnotes
Cnotes
Muthuganesh S
 
Programming in C
Programming in CProgramming in C
Programming in C
DrPrabakaranPerumal
 
venkatesh.pptx
venkatesh.pptxvenkatesh.pptx
venkatesh.pptx
KishoreRedla
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
JoselitoJMebolos
 
C language ppt
C language pptC language ppt
C language ppt
Ğäùråv Júñêjå
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
Mithun DSouza
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
 
Unit No 2.pptx Basic s of C Programming
Unit No 2.pptx   Basic s of C ProgrammingUnit No 2.pptx   Basic s of C Programming
Unit No 2.pptx Basic s of C Programming
Vaibhav Parjane
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
424769021-1-First-C-Program-1-ppt (1).ppt
424769021-1-First-C-Program-1-ppt (1).ppt424769021-1-First-C-Program-1-ppt (1).ppt
424769021-1-First-C-Program-1-ppt (1).ppt
advRajatSharma
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
sachindane
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
amol_chavan
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
sscprep9
 
C Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdfC Programming Language Introduction and C Tokens.pdf
C Programming Language Introduction and C Tokens.pdf
poongothai11
 
The New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of theThe New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of the
shubhamgupta7133
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
Mithun DSouza
 

Recently uploaded (20)

Lecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomicLecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomic
mdrakibhasan1427
 
SAFETY BRIEFING.........................
SAFETY BRIEFING.........................SAFETY BRIEFING.........................
SAFETY BRIEFING.........................
BalaChandran458212
 
RightShip-Inspection-Maritime-Safety-Simplified.pptx
RightShip-Inspection-Maritime-Safety-Simplified.pptxRightShip-Inspection-Maritime-Safety-Simplified.pptx
RightShip-Inspection-Maritime-Safety-Simplified.pptx
ultronmeg
 
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDHSEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
123candemet2003
 
CHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptxCHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptx
72200337
 
!Warshauer Paul Curriculum Vitae, Resume
!Warshauer Paul Curriculum Vitae, Resume!Warshauer Paul Curriculum Vitae, Resume
!Warshauer Paul Curriculum Vitae, Resume
PaulWarshauer1
 
Huckel_MO_Theory_Colorful_Presentation (1).pptx
Huckel_MO_Theory_Colorful_Presentation (1).pptxHuckel_MO_Theory_Colorful_Presentation (1).pptx
Huckel_MO_Theory_Colorful_Presentation (1).pptx
study2022bsc
 
Green Colorful House Simple Illustration Presentation.pdf.pdf
Green Colorful House Simple Illustration Presentation.pdf.pdfGreen Colorful House Simple Illustration Presentation.pdf.pdf
Green Colorful House Simple Illustration Presentation.pdf.pdf
RhyzCharmSolis
 
Employment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptxEmployment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptx
JunaidAlvi5
 
Placement cell of college - why choose me
Placement cell of college - why choose mePlacement cell of college - why choose me
Placement cell of college - why choose me
mmanvi024
 
GENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautifulGENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautiful
12213013
 
Huckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptxHuckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptx
study2022bsc
 
History of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptxHistory of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptx
Neelesh Raipuria
 
HCollege ppt guidance and counselin.pptx
HCollege ppt guidance and counselin.pptxHCollege ppt guidance and counselin.pptx
HCollege ppt guidance and counselin.pptx
liajohn0808
 
巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单
巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单
巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单
xule9cv6nd
 
Research Project csi1 - This presentation compares popular web browsers such ...
Research Project csi1 - This presentation compares popular web browsers such ...Research Project csi1 - This presentation compares popular web browsers such ...
Research Project csi1 - This presentation compares popular web browsers such ...
bomisung0207
 
When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?
SnapJob
 
material-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptxmaterial-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptx
JyotirmayNirankari
 
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and PortugalPixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
TechMeetups
 
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.pptTraditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
XolaniRadebe7
 
Lecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomicLecture 4.pptx which is need for microeconomic
Lecture 4.pptx which is need for microeconomic
mdrakibhasan1427
 
SAFETY BRIEFING.........................
SAFETY BRIEFING.........................SAFETY BRIEFING.........................
SAFETY BRIEFING.........................
BalaChandran458212
 
RightShip-Inspection-Maritime-Safety-Simplified.pptx
RightShip-Inspection-Maritime-Safety-Simplified.pptxRightShip-Inspection-Maritime-Safety-Simplified.pptx
RightShip-Inspection-Maritime-Safety-Simplified.pptx
ultronmeg
 
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDHSEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
SEMINAR REPORT PPT.pptxSDJADADGGDYSADGSGJSFDH
123candemet2003
 
CHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptxCHAPTER 7 - Foreign Direct Investment.pptx
CHAPTER 7 - Foreign Direct Investment.pptx
72200337
 
!Warshauer Paul Curriculum Vitae, Resume
!Warshauer Paul Curriculum Vitae, Resume!Warshauer Paul Curriculum Vitae, Resume
!Warshauer Paul Curriculum Vitae, Resume
PaulWarshauer1
 
Huckel_MO_Theory_Colorful_Presentation (1).pptx
Huckel_MO_Theory_Colorful_Presentation (1).pptxHuckel_MO_Theory_Colorful_Presentation (1).pptx
Huckel_MO_Theory_Colorful_Presentation (1).pptx
study2022bsc
 
Green Colorful House Simple Illustration Presentation.pdf.pdf
Green Colorful House Simple Illustration Presentation.pdf.pdfGreen Colorful House Simple Illustration Presentation.pdf.pdf
Green Colorful House Simple Illustration Presentation.pdf.pdf
RhyzCharmSolis
 
Employment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptxEmployment Communication : The Job HUnting.pptx
Employment Communication : The Job HUnting.pptx
JunaidAlvi5
 
Placement cell of college - why choose me
Placement cell of college - why choose mePlacement cell of college - why choose me
Placement cell of college - why choose me
mmanvi024
 
GENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautifulGENERAL INFORMATION for the most beautiful
GENERAL INFORMATION for the most beautiful
12213013
 
Huckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptxHuckel_Molecular orbital _Theory_8_Slides.pptx
Huckel_Molecular orbital _Theory_8_Slides.pptx
study2022bsc
 
History of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptxHistory of Entomology and current updates of entomology.pptx
History of Entomology and current updates of entomology.pptx
Neelesh Raipuria
 
HCollege ppt guidance and counselin.pptx
HCollege ppt guidance and counselin.pptxHCollege ppt guidance and counselin.pptx
HCollege ppt guidance and counselin.pptx
liajohn0808
 
巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单
巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单
巴利亚多利德大学毕业证书学校原版文凭补办UVa成绩单办本科成绩单
xule9cv6nd
 
Research Project csi1 - This presentation compares popular web browsers such ...
Research Project csi1 - This presentation compares popular web browsers such ...Research Project csi1 - This presentation compares popular web browsers such ...
Research Project csi1 - This presentation compares popular web browsers such ...
bomisung0207
 
When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?When Is the Best Time to Use Job Finding Apps?
When Is the Best Time to Use Job Finding Apps?
SnapJob
 
material-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptxmaterial-17438335 to the third floor in 47-gsms.pptx
material-17438335 to the third floor in 47-gsms.pptx
JyotirmayNirankari
 
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and PortugalPixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
Pixida, Simplifying Success in Germany, the USA, Brazil, China and Portugal
TechMeetups
 
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.pptTraditional Medicine aDRTYSRTYSRTnd HIV.ppt
Traditional Medicine aDRTYSRTYSRTnd HIV.ppt
XolaniRadebe7
 
Ad

PART-1 Over View of C language ( engineering)

  • 1. DATA STRUCTURES – R19 Course Code-A5502 Part -1: Overview of C Structure of a C program, data types, operators, type conversion, formatted input/out functions, Control statements. 1. Structure of a C Program 1. Documentations (Documentation Section) The Documentation section usually contains the collection of comment lines giving the name of the program, author's or programmer's name and few other details. Comments:  Comments are a way of explaining what makes a program.  The compiler ignores comments  Comment can be used anywhere in the program to add info about the program or code block  Used by other users /programmers to understand the code. The comments are specified as a) Single line comment E.g.: // Program to find factorial b) Multi line comment
  • 2. DATA STRUCTURES – R19 Course Code-A5502 E.g.: /* Program Name is – Factorial Author Name is – Ramesh Outcome – Understand loop */ 2. Preprocessor Statements (Link Section) This instructs the compiler to connect to the various functions from the system library 3. Definition Section The Definition section describes all the symbolic-constant. 4. Global Declarations (Definition Section) Used to define those variables that are used globally within the entire program and is used in more than one function. This section also declares all the user-defined functions. 5. The main() function All C programs must have a main () which contains two parts: Declaration part: Used to declare all variables that will be used within the program. In C Variables must be declared before using in the program statements. Execution part: At least one statement for execution  These two parts are declared within the opening and closing curly braces of the main ().  The execution of the program begins at the opening brace '{' and ends with the closing brace '}'.  All the statements of these two parts need to be terminated with a semi-colon. 6. User Defined Functions Deals with all user-defined functions that are called from the main () User-defined functions are declared and usually defined after the main () function. Every C program must consist of one or more functions Every function has one or more statements to perform a task. Every C program must have function main (), the execution of a C program begins with this function. It is an entry point for a C Program.
  • 3. DATA STRUCTURES – R19 Course Code-A5502 2. Data types in C C language is rich in its data types. The Data type determines The type of value a data item can have. The range of values a data item can take. The size of data item in memory bytes. Possible Operations performed on the data. C- Supports four modifiers for data types 1. signed - For Positive and Negative Value 2. unsigned - For positive only 3. short - size specifier 4. long - size specifier
  • 4. DATA STRUCTURES – R19 Course Code-A5502 The Primitive/Primary/ Basic data types in C are 1. char: It stores a single character and requires a single byte of memory in almost all compilers. o C – Language uses ASCII character set. o Characters are stored in their ASCII codes (American Standard Code for Information Interchange). o ASCII Character set uses 128 characters from 0-127. (1 Byte) o ASCII Value of A -> 65 , a->97 , 0 ->48 2. int: It is used to store integer value. (2 Bytes) 3. float: It is used to store floating point value with single precision. (4 Bytes) 4. double: It is used to store floating point value with double precision. (8 Bytes) 5. void: It has no value. It is used to specify the type of functions. If the function is void then it will not return any value. Note: The size of Data type varies from one System to another.
  • 5. DATA STRUCTURES – R19 Course Code-A5502 The basic data types and their sizes S.No Data Type Size in Bytes Range 1 char 1 -128 to +127 2 unsigned char 1 0 to 255 3 signed char 1 -128 to +127 4 int 2 -32768 to +32767 5 unsigned int 2 0 to 65535 6 signed int 2 -32768 to +32767 7 short int 2 -32768 to +32767 8 unsigned short int 2 0 to 65535 9 signed short int 2 -32768 to +32767 10 long int 4 -2147483648 to +21474833647 11 unsigned long int 4 0 to 4294967295 12 signed long int 4 -2147483648 to +21474833647 13 float 4 3.4E-38 to 3.4E+38 14 double 8 1.7E-308 to 1.7E+308 15 long double 10 3.4E-4932 to 1.1E+4932 Identifiers in C  Identifiers are names given to program elements such as variables, arrays, and functions.  The name of identifier is formed with any sequence of letters (upper and lower case), numerals and underscore (_). [Alpha numeric characters only] Rules for forming identifiers 1. Can not include any special characters or punctuation marks except underscore. E.g. @avg, avg# 2. Key words cannot be used as identifier names. E.g. int for; 3. Identifier must start with a letter or underscore. E.g. _avg , Avg,avg 4. Must not contain white spaces. E.g. AVG CSE 5. Identifiers are case sensitive. E.g. AVG differ from avg 6. Identifier can be of any reasonable length (only first 31 characters are significant). E.g. Average
  • 6. DATA STRUCTURES – R19 Course Code-A5502 Keywords in C Keywords are the reserved words and have a specific meaning already defined by the compiler. Keywords are a sequence of characters. Key words are the building blocks for writing C programs. All keywords must be written in lower case. Keywords cannot be used as identifier names. The meaning of a keyword cannot be changed. The list of keywords supported in C are Variables and Constants in C Variables: The primary purpose of variables is to store data in memory for later use. Variables value may change during execution. If you declare a variable in C, that means you are asking to the operating system for reserve a piece of memory with that variable name. A variable has  Name – Any valid identifier name  Value - The value of specified type  Address- The memory address where the variable stored.  Scope – The range of statements or program, the variable is visible.  Lifetime- How long the variable does exist in memory.
  • 7. DATA STRUCTURES – R19 Course Code-A5502 Syntax: type variable_name; type variable_name1, variable_name2, variable_namen; int width, height=5; //variable declaration and initialization char symbol='A'; //char declaration and initialization unsigned int count; signed short int age; float age, area; //variable declaration double d; Constants: Constants is the most fundamental and essential part of the C programming language. Constants in C are the fixed values that are used in a program, and its value remains the same during the entire execution of the program.  Constants are used to define fixed values.  Values of constants can never be changed.  Constants are also called literals.  Constants can be any of the data types.  It is considered best practice to define constants using only upper-case names.  Keyword const is used to define constants.  The constants can be integer constants, character constants, float or real constants. Syntax: const type constant_name; E.g: const int MAX=20;  const float PI=3.142;  const double SQRT_2=1.414;  const char GRADE=’A’;
  • 8. DATA STRUCTURES – R19 Course Code-A5502 3. Type Conversions
  • 9. DATA STRUCTURES – R19 Course Code-A5502
  • 10. DATA STRUCTURES – R19 Course Code-A5502
  • 11. DATA STRUCTURES – R19 Course Code-A5502
  • 12. DATA STRUCTURES – R19 Course Code-A5502 4. Formatted Input/Output Functions
  • 13. DATA STRUCTURES – R19 Course Code-A5502
  • 14. DATA STRUCTURES – R19 Course Code-A5502
  • 15. DATA STRUCTURES – R19 Course Code-A5502
  • 16. DATA STRUCTURES – R19 Course Code-A5502
  • 17. DATA STRUCTURES – R19 Course Code-A5502
  • 18. DATA STRUCTURES – R19 Course Code-A5502
  • 19. DATA STRUCTURES – R19 Course Code-A5502
  • 20. DATA STRUCTURES – R19 Course Code-A5502
  • 21. DATA STRUCTURES – R19 Course Code-A5502
  • 22. DATA STRUCTURES – R19 Course Code-A5502
  • 23. DATA STRUCTURES – R19 Course Code-A5502 5. Operators in C
  • 24. DATA STRUCTURES – R19 Course Code-A5502
  • 25. DATA STRUCTURES – R19 Course Code-A5502
  • 26. DATA STRUCTURES – R19 Course Code-A5502
  • 27. DATA STRUCTURES – R19 Course Code-A5502
  • 28. DATA STRUCTURES – R19 Course Code-A5502
  • 29. DATA STRUCTURES – R19 Course Code-A5502
  • 30. DATA STRUCTURES – R19 Course Code-A5502
  • 31. DATA STRUCTURES – R19 Course Code-A5502
  • 32. DATA STRUCTURES – R19 Course Code-A5502 Operator Precedence and Associativity  Precedence Rule decides the order in which different operators are applied in an expression.  Associativity rule decides the order in which multiple occurrences of the same level precedence operators are applied in an expression.