SlideShare a Scribd company logo
1 of 56
Introduction to ‘C’
P. Madhu Sudhana Rao
Embedded Software Developer
Presented by:
CLASS - 1
INDEX OF CONTENTS
• History of ‘C’
• Characteristics of ‘C’
• Structure of ‘C’
• Environment of ‘C’
• Elements of ‘C’
• How to Install Turbo C?
• How to Install GCC?
History of ‘C’
How it is evolved?
• Dennis Ritchie in 1970 at Bell Labs.
• UNIX Operating System.
Characteristics of ‘C’
Features of ‘C’
• Middle Level Language.
• Application Programs & System Programs.
• Small Language with 32 English words.
• Library Functions.
• Language is Extendible.
• Structured Program.
Structure of ‘C’
C PROGRAM
• Comment Section
• Preprocessor Section
• Global Declarations Section
• Main Section
• Local Declarations Section
• Logical Blocks
• Functions
• Local Declarations Section
• Logical Blocks
// C DEMO
#include<stdio.h>
#include<conio.h>
int a;
Void main()
{
char b;
------------------------------
-------------------------------
}
Func1()
{
int c;
----------------------------------
----------------------------------
}
COMMENTS SECTION
• Comments are programmer friendly.
• Compiler will never execute comments.
• Two types of Comments
– Single Line Comment
• Syntax: // ……………….
– Multiple Line Comment
• Syntax: /* ………………………….
………………………….*/
PREPROCESSOR SECTION
• C PRE PROCESSOR
• Directives
• #include, #define etc…
• How to define constant value
– Syntax: #define mad 2.2
• How to include library file
– Syntax: #include <HedarFile.h>
DECLARATION SECTION
• Scope
• Two Sections
– Global Declaration
• Syntax: Data_Type Variable_name;
– Local Declaration
• Syntax: Data_Type Variable_name;
Later ….
Functions, Logical Blocks can be discussed later
and nothing to worry at this point of time.
Environment of ‘C’
COMPILATION PROCESS
SOURCE CODE
PRE PROCESSOR
COMPILER
ASSEMBLER
LINKER
EXECUTABLE CODE
EXPANDED CODE
ASSEMBLY CODE
OBJECT CODE
OTHER OBJECT FILES
LIBRARIES
Two Compilers
• Download Turbo C from Google Drive.
• Download Code Blocks from Google Drive.
Follow the PRESENTATION…
In the practical session, download and install them
ELEMENTS OF ‘C’
BASIC ELEMENTS
• Character Set
• Keywords
• Identifiers
• Data Types
• Constants
• Variables
• Expressions
• Statements
• Comments
CHARACTER SET
• Alphabets [a-z, A-Z]
• Digits [0 – 9]
• Escape Sequences
ESCAPE SEQUENCE MEANING
b BACKSPACE
a ALERT
r CARRIAGE RETURN
n NEWLINE
0 NULL
t HORIZONTAL TAB
 BACKSLASH
KEYWORDS
• Lowercase
• 32 Keywords in ‘C’
auto; break; case; char; const; continue;
default;do;double;else;enum;extern;float;for;
goto;if;int;long;register;return;short;signed;
sizeof;static;struct;switch;typedef;union;
unsigned;void;volatile;while
IDENTIFIERS
• Words  Keywords or Identifiers
• Rules:
– The name should consist of alphabets, digits and underscore sign.
– First character should be an alphabet or underscore.
– The name should not be a keyword.
– Since C is case sensitive, the upper case and lower case are different.
– An identifier name may be arbitrarily long.
• Only 8 preferable and upto 31.
5bc int rec# avg no
DATA TYPES
• Memory Allocation
• Four Fundamental
– int, char, float, double
• Size Qualifiers
– short, long
• Sign Qualifiers
– signed, unsigned
BASIC DATA
TYPE
DATA TYPE SIZE RANGE
char char or signed char 1 -128 to 127
unsigned char 1 0 to 255
Int int or signed int 4 -2147483648 to +2147483647
unsigned int 4 0 to 4294967295
Short int or signed short
int
2 -32768 to +32767
Unsigned short int 2 0 to 65535
Long int or signed long int 4 -2147483648 to +2147483647
Unsigned long int 4 0 to 4294967295
float float 4 3.4E-38 to 3.4E+38
double double 8 1.7E-308 to 1.7E+308
long double 10 3.4D-4932 to 1.1E+4932
32-BIT MACHINE DATA TYPES
CONSTANTS
• Can’t be changed throughout the execution
• 3 Types of Constants
– Numeric Constants
• Integer Constants
• Real Constants
– Character Constants
– String Constants
VARIABLES
• Store a value
• Declaration of Variables
– Syntax: int x;
• Initialization of Variables
– Syntax: int x=5;
EXPRESSIONS
• Arithmetic Expressions
– Syntax: x+y;
• Relational Expressions
– Syntax: a>b;
• Logical Expressions
– Syntax: a==b;
• Function Calls
– Syntax: func(a,b);
STATEMENTS
• Expression Statements [x=5, x=y-z]
• Compound Statements [x*y*z+y*z+z*x]
• Selection Statements [if, if…else,switch]
• Iterative Statements [for, while, do…while]
• Jump Statements [goto, continue, break, ret]
• Label Statements [case, default, goto label]
COMMENTS
• Increases the readability of a program.
• Write anywhere in the program.
• Comments can’t be nested.
• Can’t be written inside string constant or a
character constant.
QUERIES
CONTACT
P. Madhu Sudhana Rao
Embedded Software Developer
Orange Research Labs
@: msr@orangeresearchlabs.com
WWW: madresearch.wordpress.com
I/O, OPERATORS in ‘C’
P. Madhu Sudhana Rao
Embedded Software Developer
Presented by:
CLASS - 2
INDEX OF CONTENTS
• Conversion Specifications
• Reading Input Data
• Writing Output Data
• getchar() and putchar()
• Operators
• Types
• Precedence and Associativity of Operators
CONVERSION SPECIFICATIONS
%
• %C Single Character
• %d Decimal Integer
• %f  Floating Point Number
• %o  Octal Integer
• %x  Hexa Decimal Integer
• %s  String
• %u  Unsigned Decimal Integer
READING INPUT DATA
SCANF ()
• Used to read the data.
• Minimum no of Arguments: 2
• Returns the no of variables read.
Syntax:
scanf(“control string”, add1, add2…);
WRITING OUTPUT DATA
PRINTF ()
• Used to write the data.
• Minimum no of arguments: 1
• Returns the no of characters printed.
Syntax:
printf(“control string”, variable1, variable2…);
Getchar () and Putchar()
• To read a character, then get
Syntax: ch=getchar();
• To write a character, then put
Syntax: putchar(ch);
OPERATORS
Types of Operators
• Arithmetic Operators
• Assignment Operators
• Increment and Decrement Operators
• Relational Operators
• Logical Operators
• Conditional Operators
• Comma Operators
• sizeof Operators
• Bitwise Operators
Arithmetical Operators
• Unary Arithmetic Operators
• Binary Arithmetic Operators
Examples [Unary]: +x, -y
Examples [Binary]: +, -, *, /, %
Assignment Operators
• Storing of a value.
• Left Hand Side: Variable.
• Right Hand Side: Value.
Examples:
X=8, s=x+y-2, y=x
X+=5 [+= Compound Assignment Operator]
Increment and Decrement
Operators
• Increment (++)
• Decrement (--)
• Prefix
• Postfix
Relational Operators
• Comparison
• <, <=, >, >=, ==, !=
Logical or Boolean Operators
• AND (&&), OR (||), NOT (!)
Conditional Operators
• ?:
• TestExpression?Expression1:Expression2
• True  Expression1
• False  Expression2
Comma Operator
• Comma separates the expressions.
sizeof Operator
• Sizeof is an unary operator.
Syntax: sizeof(variable);
Bitwise Operators
• Bitwise AND (&),
• Bitwise OR (|),
• One’s Complement (~),
• Bitwise Left Shift (<<),
• Bitwise Right Shift (>>),
• Bitwise XOR (^)
Associativity of Operators
Operators Associativity
::a a::b left to right
a() a[b] a->b a[b..c] ({}) ([]) (<>) left to right
a++ a-- left to right
!a ~a (type)a ++a --a right to left!
a*b a/b a%b left to right
a+b a-b left to right
a>>b a<<b left to right
a>b a>=b a<b a<=b left to right
a==b a!=b left to right
a&b left to right
a^b left to right
a|b left to right
&& left to right
|| left to right
a?b:c right to left
= += -= *= /= %= <<= >>= &= |= ^=
right to left
@a right to left
, left to right
Examples
This expression is evaluated in this order
1+2*2 1+(2*2)
1+2*2*4 1+((2*2)*4)
(1+2)*2*4 ((1+2)*2)*4
1+4,c=2|3+5 (1+4),(c=(2|(3+5)))
1 + 5&4 == 3 (1 + 5) & (4 == 3)
c=1,99 (c=1),99
!a++ + ~f() (!(a++)) + (~(f()))
s == “mad" || i < 9 (s == “mad") || (i < 9)
r = s == “mad" r = (s == “mad")
QUERIES
CONTACT
P. Madhu Sudhana Rao
Embedded Software Developer
Orange Research Labs
@: msr@orangeresearchlabs.com
WWW: madresearch.wordpress.com

More Related Content

What's hot

What's hot (19)

C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
 
Programming C Language
Programming C LanguageProgramming C Language
Programming C Language
 
C language basics
C language basicsC language basics
C language basics
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Session 06 - Java Basics
Session 06 - Java BasicsSession 06 - Java Basics
Session 06 - Java Basics
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
 
C language programming
C language programmingC language programming
C language programming
 
C Programming basics
C Programming basicsC Programming basics
C Programming basics
 
C - - Grammar 1.0
C - - Grammar 1.0C - - Grammar 1.0
C - - Grammar 1.0
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Perl Intro 3 Datalog Parsing
Perl Intro 3 Datalog ParsingPerl Intro 3 Datalog Parsing
Perl Intro 3 Datalog Parsing
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c language
 

Similar to c

Similar to c (20)

Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
 
C
CC
C
 
Lec-1c.pdf
Lec-1c.pdfLec-1c.pdf
Lec-1c.pdf
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
C language
C languageC language
C language
 
Basics of c
Basics of cBasics of c
Basics of c
 
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
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Funa-C.ppt
Funa-C.pptFuna-C.ppt
Funa-C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 

Recently uploaded

VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...Suhani Kapoor
 
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...shivangimorya083
 
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...Suhani Kapoor
 
Employee of the Month - Samsung Semiconductor India Research
Employee of the Month - Samsung Semiconductor India ResearchEmployee of the Month - Samsung Semiconductor India Research
Employee of the Month - Samsung Semiconductor India ResearchSoham Mondal
 
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Ioannis Tzachristas Self-Presentation for MBA.pdf
Ioannis Tzachristas Self-Presentation for MBA.pdfIoannis Tzachristas Self-Presentation for MBA.pdf
Ioannis Tzachristas Self-Presentation for MBA.pdfjtzach
 
The Impact of Socioeconomic Status on Education.pdf
The Impact of Socioeconomic Status on Education.pdfThe Impact of Socioeconomic Status on Education.pdf
The Impact of Socioeconomic Status on Education.pdftheknowledgereview1
 
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...Suhani Kapoor
 
Experience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdfExperience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdfSoham Mondal
 
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfNPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfDivyeshPatel234692
 
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service CuttackVIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service CuttackSuhani Kapoor
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...shivangimorya083
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiSuhani Kapoor
 
CFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector ExperienceCFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector ExperienceSanjay Bokadia
 
Internshala Student Partner 6.0 Jadavpur University Certificate
Internshala Student Partner 6.0 Jadavpur University CertificateInternshala Student Partner 6.0 Jadavpur University Certificate
Internshala Student Partner 6.0 Jadavpur University CertificateSoham Mondal
 
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With RoomVIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Roomdivyansh0kumar0
 
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一2s3dgmej
 
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service CuttackVIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service CuttackSuhani Kapoor
 
Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call Girls
Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call GirlsSonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call Girls
Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call GirlsNiya Khan
 

Recently uploaded (20)

VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
 
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
Full Masii Russian Call Girls In Dwarka (Delhi) 9711199012 💋✔💕😘We are availab...
 
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
Low Rate Call Girls Gorakhpur Anika 8250192130 Independent Escort Service Gor...
 
Employee of the Month - Samsung Semiconductor India Research
Employee of the Month - Samsung Semiconductor India ResearchEmployee of the Month - Samsung Semiconductor India Research
Employee of the Month - Samsung Semiconductor India Research
 
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Ioannis Tzachristas Self-Presentation for MBA.pdf
Ioannis Tzachristas Self-Presentation for MBA.pdfIoannis Tzachristas Self-Presentation for MBA.pdf
Ioannis Tzachristas Self-Presentation for MBA.pdf
 
The Impact of Socioeconomic Status on Education.pdf
The Impact of Socioeconomic Status on Education.pdfThe Impact of Socioeconomic Status on Education.pdf
The Impact of Socioeconomic Status on Education.pdf
 
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCeCall Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
 
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
 
Experience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdfExperience Certificate - Marketing Analyst-Soham Mondal.pdf
Experience Certificate - Marketing Analyst-Soham Mondal.pdf
 
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfNPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
 
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service CuttackVIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
 
CFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector ExperienceCFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector Experience
 
Internshala Student Partner 6.0 Jadavpur University Certificate
Internshala Student Partner 6.0 Jadavpur University CertificateInternshala Student Partner 6.0 Jadavpur University Certificate
Internshala Student Partner 6.0 Jadavpur University Certificate
 
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With RoomVIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Room
 
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
 
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service CuttackVIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
 
Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call Girls
Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call GirlsSonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call Girls
Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call Girls
 

c

  • 1. Introduction to ‘C’ P. Madhu Sudhana Rao Embedded Software Developer Presented by: CLASS - 1
  • 2. INDEX OF CONTENTS • History of ‘C’ • Characteristics of ‘C’ • Structure of ‘C’ • Environment of ‘C’ • Elements of ‘C’ • How to Install Turbo C? • How to Install GCC?
  • 4. How it is evolved? • Dennis Ritchie in 1970 at Bell Labs. • UNIX Operating System.
  • 6. Features of ‘C’ • Middle Level Language. • Application Programs & System Programs. • Small Language with 32 English words. • Library Functions. • Language is Extendible. • Structured Program.
  • 8. C PROGRAM • Comment Section • Preprocessor Section • Global Declarations Section • Main Section • Local Declarations Section • Logical Blocks • Functions • Local Declarations Section • Logical Blocks // C DEMO #include<stdio.h> #include<conio.h> int a; Void main() { char b; ------------------------------ ------------------------------- } Func1() { int c; ---------------------------------- ---------------------------------- }
  • 9. COMMENTS SECTION • Comments are programmer friendly. • Compiler will never execute comments. • Two types of Comments – Single Line Comment • Syntax: // ………………. – Multiple Line Comment • Syntax: /* …………………………. ………………………….*/
  • 10. PREPROCESSOR SECTION • C PRE PROCESSOR • Directives • #include, #define etc… • How to define constant value – Syntax: #define mad 2.2 • How to include library file – Syntax: #include <HedarFile.h>
  • 11. DECLARATION SECTION • Scope • Two Sections – Global Declaration • Syntax: Data_Type Variable_name; – Local Declaration • Syntax: Data_Type Variable_name;
  • 12. Later …. Functions, Logical Blocks can be discussed later and nothing to worry at this point of time.
  • 14. COMPILATION PROCESS SOURCE CODE PRE PROCESSOR COMPILER ASSEMBLER LINKER EXECUTABLE CODE EXPANDED CODE ASSEMBLY CODE OBJECT CODE OTHER OBJECT FILES LIBRARIES
  • 15. Two Compilers • Download Turbo C from Google Drive. • Download Code Blocks from Google Drive. Follow the PRESENTATION… In the practical session, download and install them
  • 17. BASIC ELEMENTS • Character Set • Keywords • Identifiers • Data Types • Constants • Variables • Expressions • Statements • Comments
  • 18. CHARACTER SET • Alphabets [a-z, A-Z] • Digits [0 – 9] • Escape Sequences ESCAPE SEQUENCE MEANING b BACKSPACE a ALERT r CARRIAGE RETURN n NEWLINE 0 NULL t HORIZONTAL TAB BACKSLASH
  • 19. KEYWORDS • Lowercase • 32 Keywords in ‘C’ auto; break; case; char; const; continue; default;do;double;else;enum;extern;float;for; goto;if;int;long;register;return;short;signed; sizeof;static;struct;switch;typedef;union; unsigned;void;volatile;while
  • 20. IDENTIFIERS • Words  Keywords or Identifiers • Rules: – The name should consist of alphabets, digits and underscore sign. – First character should be an alphabet or underscore. – The name should not be a keyword. – Since C is case sensitive, the upper case and lower case are different. – An identifier name may be arbitrarily long. • Only 8 preferable and upto 31. 5bc int rec# avg no
  • 21. DATA TYPES • Memory Allocation • Four Fundamental – int, char, float, double • Size Qualifiers – short, long • Sign Qualifiers – signed, unsigned
  • 22. BASIC DATA TYPE DATA TYPE SIZE RANGE char char or signed char 1 -128 to 127 unsigned char 1 0 to 255 Int int or signed int 4 -2147483648 to +2147483647 unsigned int 4 0 to 4294967295 Short int or signed short int 2 -32768 to +32767 Unsigned short int 2 0 to 65535 Long int or signed long int 4 -2147483648 to +2147483647 Unsigned long int 4 0 to 4294967295 float float 4 3.4E-38 to 3.4E+38 double double 8 1.7E-308 to 1.7E+308 long double 10 3.4D-4932 to 1.1E+4932 32-BIT MACHINE DATA TYPES
  • 23. CONSTANTS • Can’t be changed throughout the execution • 3 Types of Constants – Numeric Constants • Integer Constants • Real Constants – Character Constants – String Constants
  • 24. VARIABLES • Store a value • Declaration of Variables – Syntax: int x; • Initialization of Variables – Syntax: int x=5;
  • 25. EXPRESSIONS • Arithmetic Expressions – Syntax: x+y; • Relational Expressions – Syntax: a>b; • Logical Expressions – Syntax: a==b; • Function Calls – Syntax: func(a,b);
  • 26. STATEMENTS • Expression Statements [x=5, x=y-z] • Compound Statements [x*y*z+y*z+z*x] • Selection Statements [if, if…else,switch] • Iterative Statements [for, while, do…while] • Jump Statements [goto, continue, break, ret] • Label Statements [case, default, goto label]
  • 27. COMMENTS • Increases the readability of a program. • Write anywhere in the program. • Comments can’t be nested. • Can’t be written inside string constant or a character constant.
  • 29.
  • 30. CONTACT P. Madhu Sudhana Rao Embedded Software Developer Orange Research Labs @: msr@orangeresearchlabs.com WWW: madresearch.wordpress.com
  • 31. I/O, OPERATORS in ‘C’ P. Madhu Sudhana Rao Embedded Software Developer Presented by: CLASS - 2
  • 32. INDEX OF CONTENTS • Conversion Specifications • Reading Input Data • Writing Output Data • getchar() and putchar() • Operators • Types • Precedence and Associativity of Operators
  • 34. % • %C Single Character • %d Decimal Integer • %f  Floating Point Number • %o  Octal Integer • %x  Hexa Decimal Integer • %s  String • %u  Unsigned Decimal Integer
  • 36. SCANF () • Used to read the data. • Minimum no of Arguments: 2 • Returns the no of variables read. Syntax: scanf(“control string”, add1, add2…);
  • 38. PRINTF () • Used to write the data. • Minimum no of arguments: 1 • Returns the no of characters printed. Syntax: printf(“control string”, variable1, variable2…);
  • 39. Getchar () and Putchar() • To read a character, then get Syntax: ch=getchar(); • To write a character, then put Syntax: putchar(ch);
  • 41. Types of Operators • Arithmetic Operators • Assignment Operators • Increment and Decrement Operators • Relational Operators • Logical Operators • Conditional Operators • Comma Operators • sizeof Operators • Bitwise Operators
  • 42. Arithmetical Operators • Unary Arithmetic Operators • Binary Arithmetic Operators Examples [Unary]: +x, -y Examples [Binary]: +, -, *, /, %
  • 43. Assignment Operators • Storing of a value. • Left Hand Side: Variable. • Right Hand Side: Value. Examples: X=8, s=x+y-2, y=x X+=5 [+= Compound Assignment Operator]
  • 44. Increment and Decrement Operators • Increment (++) • Decrement (--) • Prefix • Postfix
  • 46. Logical or Boolean Operators • AND (&&), OR (||), NOT (!)
  • 47. Conditional Operators • ?: • TestExpression?Expression1:Expression2 • True  Expression1 • False  Expression2
  • 48. Comma Operator • Comma separates the expressions.
  • 49. sizeof Operator • Sizeof is an unary operator. Syntax: sizeof(variable);
  • 50. Bitwise Operators • Bitwise AND (&), • Bitwise OR (|), • One’s Complement (~), • Bitwise Left Shift (<<), • Bitwise Right Shift (>>), • Bitwise XOR (^)
  • 52. Operators Associativity ::a a::b left to right a() a[b] a->b a[b..c] ({}) ([]) (<>) left to right a++ a-- left to right !a ~a (type)a ++a --a right to left! a*b a/b a%b left to right a+b a-b left to right a>>b a<<b left to right a>b a>=b a<b a<=b left to right a==b a!=b left to right a&b left to right a^b left to right a|b left to right && left to right || left to right a?b:c right to left = += -= *= /= %= <<= >>= &= |= ^= right to left @a right to left , left to right
  • 53. Examples This expression is evaluated in this order 1+2*2 1+(2*2) 1+2*2*4 1+((2*2)*4) (1+2)*2*4 ((1+2)*2)*4 1+4,c=2|3+5 (1+4),(c=(2|(3+5))) 1 + 5&4 == 3 (1 + 5) & (4 == 3) c=1,99 (c=1),99 !a++ + ~f() (!(a++)) + (~(f())) s == “mad" || i < 9 (s == “mad") || (i < 9) r = s == “mad" r = (s == “mad")
  • 55.
  • 56. CONTACT P. Madhu Sudhana Rao Embedded Software Developer Orange Research Labs @: msr@orangeresearchlabs.com WWW: madresearch.wordpress.com