SlideShare une entreprise Scribd logo
1  sur  20
Static Storage Class 
Storage 
Default Initial Value 
Scope 
Life 
Memory 
0 
Local to the block in which 
the variable is defined 
Variable persists between 
different function calls
main( ) 
{ 
increment( ) ; 
increment( ) ; 
increment( ) ; 
} 
increment( ) 
{ 
auto int i = 1 ; 
register int j = 1 ; 
static int k = 1 ; 
i++ ; 
j++ ; k++ ; 
printf ( ”%d %d %d”, i, j, k ) ; 
2 2 2 
2 2 3 
2 2 4 
}
When to Use Static 
main( ) 
{ 
f( ) 
f( ) ; 
p = 
int a = 20 ; 
return ( &a ) ; 
} 
printf ( ”%d”, *p ) ; 
} 
int *p ; int * f( ) ; 
{ 
a p 
20 250 
250 
int * f( ) char ** char ** ff (( iinntt **,, ffllooaatt ** )) ;; 
static int a = 20 ;
External Storage Class 
main( ) 
{ 
printf ( ”%d”, a ) ; 
increment( ) ; 
increment( ) ; 
decrement( ) ; 
printf ( ”%d”, a ) ; 
} 
increment( ) 
{ 
a++ ; printf ( ”%d”, a ) ; 
} decrement( ) 
{ 
a-- ; printf ( ”%d”, a ) ; 
} 
10 
11 
12 
11 
11 
int a = 10 ; 
Output
Declaration V/s Definition main( ) 
{ 
extern int a ; 
printf ( ”%d”, a ) ; 
increment( ) ; 
increment( ) ; 
decrement( ) ; 
printf ( ”%d”, a ) ; 
ncrement( ) 
{ 
extern int a ; 
float square ( float ) ; 
float square ( float ) 
{ 
.. 
.. 
} 
DDeeccllaarraattiioonn 
} a++ ; printf ( ”%d”, a ) ; 
decrement( ) 
{ 
extern int a ; 
} a-- ; printf ( ”%d”, a ) ; 
}i 
int a = 10 ; 
DDeeccllaarraattiioonn 
DDeeccllaarraattiioonn 
DDeeffiinniittiioonn 
float square ( float ) ; 
float square ( float ) 
{ 
.. 
.. 
} 
DDeeffiinniittiioonn
Declaration V/s Definition main( ) 
{ 
extern int a ; 
printf ( ”%d”, a ) ; 
increment( ) ; 
increment( ) ; 
decrement( ) ; 
printf ( ”%d”, a ) ; 
extern int a ; 
int a = 10 ; 
decrement( ) 
{ 
extern int a ; 
}i 
ncrement( ) 
{ 
a++ ; printf ( ”%d”, a ) ; 
} 
a-- ; printf ( ”%d”, a ) ; 
}
Declaration V/s Definition main( ) 
{ 
extern int a ; 
printf ( ”%d”, a ) ; 
increment( ) ; 
increment( ) ; 
decrement( ) ; 
printf ( ”%d”, a ) ; 
int a = 10 ; 
increment( ) 
{ 
extern int a ; 
decrement( ) 
{ 
extern int a ; 
} 
a++ ; printf ( ”%d”, a ) ; 
} 
a-- ; printf ( ”%d”, a ) ; 
}
Two Types Of Conflicts 
int a = 10 ; 
main( ) 
{ 
int a = 20 ; 
{ 
int a = 30 ; 
printf ( ”%d”, a ) ; 
} 
printf ( ”%d”, a ) ; 
} 
printf ( ”%d”, a ) ; 
30 
20
External Storage Class 
Storage 
Default Initial Value 
Scope 
Life 
Memory 
0 
Global 
Till execution of the 
program doesn’t end
Which is The Most Powerful 
 Automatic 
 Register 
 Static 
 External 
All other cases 
For frequently 
used variables 
If variable is to live 
across function calls 
If variable required by 
all functions
Ctrl F9 
F9 
F7 
F8 
C Preprocessor 
Compile and Execute 
Compile 
Step into 
Step over
main( ) 
{ 
int a = 10 ; 
float b = 3.5 ; 
display( ) ; 
printf ( ”Hello” ) ; 
} display( ) 
{ 
printf ( ”Nagpur” ) ; 
}
A Closer Look 
Hand written program 
Text Editor 
C Source Code 
Preprocessor 
Expanded source code 
Compiler 
Object code 
Linker 
Executable code 
C : 
Helps in typing TC 
WS4 . . 
a program 
WORKS 
Helps in typing 
a program 
Expands the 
source code 
Expands the 
source code 
Converts expanded source 
code into machine language 
Converts expanded source 
code into machine language
Why IDE 
 Editor 
 Preprocessor 
 Compiler 
 Linker 
Ctrl F9 
TTuurrbboo CC//CC++++ 
Preprocesses, 
Compiles, Links 
and Executes
Types of Preprocessor Directives 
File Inclusion 
Macro Expansion 
Conditional Compilation 
Miscellaneous Directives
Preprocessor In Action 
# include ”goto.c” 
main( ) 
{ 
Compiler 
clrscr( ) ; 
gotorc ( 10, 20 ) ; 
printf ( ”Hello !” ) ; 
} 
Source Code 
Ctrl F9 
Preprocessor 
main( ) 
{ 
clrscr( ) ; 
gotorc ( 10, 20 ) ; 
printf ( ”Hello !” ) ; 
} 
gotorc( - , - ) 
{ 
- 
- 
- 
} 
Expanded source code
Unresolved 
Externals 
gotorc( - , - ) 
{ 
- 
- 
- 
} Compiler 
main( ) 
{ 
- 
- 
- 
} 
machine language 
code of gotorc( ) 
machine language 
code of main( ) 
Error Why?
Solution 
m/c language code 
of gotorc( ) 
m/c language code 
of main( ) 
m/c language code 
of clrscr( ) 
m/c language code 
of printf( ) 
LLiinnkkeerr 
Executable code
Your wish 
# include ”goto.c” 
# include goto.c 
C : 
TC 
WS4 . . 
WORKS 
INCLUDE 
INCLUDE DIRECTORIES 
LIBRARY DIRECTORIES 
C: TC INCLUDE 
C: TC LIB 
C: TC WORKS 
C: TC 
OUTPUT DIRECTORY 
SOURCE DIRECTORIES
CChhaapptteerr 66 
CChhaapptteerr 66

Contenu connexe

Tendances

Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start sedalipkumar64
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphismmohamed sikander
 
Simple c program
Simple c programSimple c program
Simple c programRavi Singh
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd StudyChris Ohk
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloadingmohamed sikander
 
lFuzzer - Learning Input Tokens for Effective Fuzzing
lFuzzer - Learning Input Tokens for Effective FuzzinglFuzzer - Learning Input Tokens for Effective Fuzzing
lFuzzer - Learning Input Tokens for Effective FuzzingBjörn Mathis
 
All VLSI programs
All VLSI programsAll VLSI programs
All VLSI programsGouthaman V
 
Program flowchart
Program flowchartProgram flowchart
Program flowchartSowri Rajan
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13Chris Ohk
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐานKrunee Thitthamon
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++ Arun Nair
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C LanguageRAJWANT KAUR
 

Tendances (20)

C exam
C examC exam
C exam
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphism
 
Simple c program
Simple c programSimple c program
Simple c program
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
lFuzzer - Learning Input Tokens for Effective Fuzzing
lFuzzer - Learning Input Tokens for Effective FuzzinglFuzzer - Learning Input Tokens for Effective Fuzzing
lFuzzer - Learning Input Tokens for Effective Fuzzing
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
All VLSI programs
All VLSI programsAll VLSI programs
All VLSI programs
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
 
First c program
First c programFirst c program
First c program
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
C Programming
C ProgrammingC Programming
C Programming
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 

En vedette

CONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAX
CONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAXCONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAX
CONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAXAndReita MendOza
 
WordPress Security 101: Essential Security Practices Simplified
WordPress Security 101: Essential Security Practices SimplifiedWordPress Security 101: Essential Security Practices Simplified
WordPress Security 101: Essential Security Practices SimplifiedBlogVault Inc
 
Web hacking-dvwa-publish-130131073605-phpapp01
Web hacking-dvwa-publish-130131073605-phpapp01Web hacking-dvwa-publish-130131073605-phpapp01
Web hacking-dvwa-publish-130131073605-phpapp01Jalil Mashab-Crew
 
State of WordPress Security: Today and Beyond
State of WordPress Security: Today and BeyondState of WordPress Security: Today and Beyond
State of WordPress Security: Today and BeyondBlogVault Inc
 
Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...
Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...
Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...Dr Suresh Pandey
 

En vedette (10)

CONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAX
CONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAXCONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAX
CONFIGURACIÓN Y ADMINISTRACIÓN DE IMPRESORAS Y FAX
 
Data representation UNIT-1
Data representation UNIT-1Data representation UNIT-1
Data representation UNIT-1
 
WordPress Security 101: Essential Security Practices Simplified
WordPress Security 101: Essential Security Practices SimplifiedWordPress Security 101: Essential Security Practices Simplified
WordPress Security 101: Essential Security Practices Simplified
 
Proposal Real
Proposal RealProposal Real
Proposal Real
 
Web hacking-dvwa-publish-130131073605-phpapp01
Web hacking-dvwa-publish-130131073605-phpapp01Web hacking-dvwa-publish-130131073605-phpapp01
Web hacking-dvwa-publish-130131073605-phpapp01
 
State of WordPress Security: Today and Beyond
State of WordPress Security: Today and BeyondState of WordPress Security: Today and Beyond
State of WordPress Security: Today and Beyond
 
Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...
Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...
Pearls for Tackling canalicular injuries of Lacrimal Apparatus Presentation b...
 
DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
 
Percaya diri
Percaya diriPercaya diri
Percaya diri
 

Similaire à Vcs15

'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c programNishmaNJ
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar B Kute
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nmmohamed sikander
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfYashwanthCse
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab FileKandarp Tiwari
 
为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?勇浩 赖
 
2. Data, Operators, IO.ppt
2. Data, Operators, IO.ppt2. Data, Operators, IO.ppt
2. Data, Operators, IO.pptswateerawat06
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143alish sha
 

Similaire à Vcs15 (20)

'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c program
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
C++ programs
C++ programsC++ programs
C++ programs
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C Basics
C BasicsC Basics
C Basics
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
 
C programs pbq final
C programs pbq finalC programs pbq final
C programs pbq final
 
为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?
 
2. Data, Operators, IO.ppt
2. Data, Operators, IO.ppt2. Data, Operators, IO.ppt
2. Data, Operators, IO.ppt
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
 
Cquestions
Cquestions Cquestions
Cquestions
 

Plus de Malikireddy Bramhananda Reddy

DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYDATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyMalikireddy Bramhananda Reddy
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit orderMalikireddy Bramhananda Reddy
 

Plus de Malikireddy Bramhananda Reddy (20)

AVL TREE PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDYAVL TREE PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
 
B-TREE PREPARED BY M V BRAHMANANDA REDDY
B-TREE PREPARED BY M V BRAHMANANDA REDDYB-TREE PREPARED BY M V BRAHMANANDA REDDY
B-TREE PREPARED BY M V BRAHMANANDA REDDY
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYDATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
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 SLIDES PREPARED BY M V B REDDY
C SLIDES PREPARED BY  M V B REDDYC SLIDES PREPARED BY  M V B REDDY
C SLIDES PREPARED BY M V B REDDY
 
C AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDYC AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDY
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
 
Vcs29
Vcs29Vcs29
Vcs29
 
Vcs28
Vcs28Vcs28
Vcs28
 
Vcs26
Vcs26Vcs26
Vcs26
 
Vcs24
Vcs24Vcs24
Vcs24
 
Vcs23
Vcs23Vcs23
Vcs23
 
Vcs22
Vcs22Vcs22
Vcs22
 
Vcs21
Vcs21Vcs21
Vcs21
 
Vcs20
Vcs20Vcs20
Vcs20
 
Vcs19
Vcs19Vcs19
Vcs19
 
Vcs17
Vcs17Vcs17
Vcs17
 

Vcs15

  • 1. Static Storage Class Storage Default Initial Value Scope Life Memory 0 Local to the block in which the variable is defined Variable persists between different function calls
  • 2. main( ) { increment( ) ; increment( ) ; increment( ) ; } increment( ) { auto int i = 1 ; register int j = 1 ; static int k = 1 ; i++ ; j++ ; k++ ; printf ( ”%d %d %d”, i, j, k ) ; 2 2 2 2 2 3 2 2 4 }
  • 3. When to Use Static main( ) { f( ) f( ) ; p = int a = 20 ; return ( &a ) ; } printf ( ”%d”, *p ) ; } int *p ; int * f( ) ; { a p 20 250 250 int * f( ) char ** char ** ff (( iinntt **,, ffllooaatt ** )) ;; static int a = 20 ;
  • 4. External Storage Class main( ) { printf ( ”%d”, a ) ; increment( ) ; increment( ) ; decrement( ) ; printf ( ”%d”, a ) ; } increment( ) { a++ ; printf ( ”%d”, a ) ; } decrement( ) { a-- ; printf ( ”%d”, a ) ; } 10 11 12 11 11 int a = 10 ; Output
  • 5. Declaration V/s Definition main( ) { extern int a ; printf ( ”%d”, a ) ; increment( ) ; increment( ) ; decrement( ) ; printf ( ”%d”, a ) ; ncrement( ) { extern int a ; float square ( float ) ; float square ( float ) { .. .. } DDeeccllaarraattiioonn } a++ ; printf ( ”%d”, a ) ; decrement( ) { extern int a ; } a-- ; printf ( ”%d”, a ) ; }i int a = 10 ; DDeeccllaarraattiioonn DDeeccllaarraattiioonn DDeeffiinniittiioonn float square ( float ) ; float square ( float ) { .. .. } DDeeffiinniittiioonn
  • 6. Declaration V/s Definition main( ) { extern int a ; printf ( ”%d”, a ) ; increment( ) ; increment( ) ; decrement( ) ; printf ( ”%d”, a ) ; extern int a ; int a = 10 ; decrement( ) { extern int a ; }i ncrement( ) { a++ ; printf ( ”%d”, a ) ; } a-- ; printf ( ”%d”, a ) ; }
  • 7. Declaration V/s Definition main( ) { extern int a ; printf ( ”%d”, a ) ; increment( ) ; increment( ) ; decrement( ) ; printf ( ”%d”, a ) ; int a = 10 ; increment( ) { extern int a ; decrement( ) { extern int a ; } a++ ; printf ( ”%d”, a ) ; } a-- ; printf ( ”%d”, a ) ; }
  • 8. Two Types Of Conflicts int a = 10 ; main( ) { int a = 20 ; { int a = 30 ; printf ( ”%d”, a ) ; } printf ( ”%d”, a ) ; } printf ( ”%d”, a ) ; 30 20
  • 9. External Storage Class Storage Default Initial Value Scope Life Memory 0 Global Till execution of the program doesn’t end
  • 10. Which is The Most Powerful Automatic Register Static External All other cases For frequently used variables If variable is to live across function calls If variable required by all functions
  • 11. Ctrl F9 F9 F7 F8 C Preprocessor Compile and Execute Compile Step into Step over
  • 12. main( ) { int a = 10 ; float b = 3.5 ; display( ) ; printf ( ”Hello” ) ; } display( ) { printf ( ”Nagpur” ) ; }
  • 13. A Closer Look Hand written program Text Editor C Source Code Preprocessor Expanded source code Compiler Object code Linker Executable code C : Helps in typing TC WS4 . . a program WORKS Helps in typing a program Expands the source code Expands the source code Converts expanded source code into machine language Converts expanded source code into machine language
  • 14. Why IDE Editor Preprocessor Compiler Linker Ctrl F9 TTuurrbboo CC//CC++++ Preprocesses, Compiles, Links and Executes
  • 15. Types of Preprocessor Directives File Inclusion Macro Expansion Conditional Compilation Miscellaneous Directives
  • 16. Preprocessor In Action # include ”goto.c” main( ) { Compiler clrscr( ) ; gotorc ( 10, 20 ) ; printf ( ”Hello !” ) ; } Source Code Ctrl F9 Preprocessor main( ) { clrscr( ) ; gotorc ( 10, 20 ) ; printf ( ”Hello !” ) ; } gotorc( - , - ) { - - - } Expanded source code
  • 17. Unresolved Externals gotorc( - , - ) { - - - } Compiler main( ) { - - - } machine language code of gotorc( ) machine language code of main( ) Error Why?
  • 18. Solution m/c language code of gotorc( ) m/c language code of main( ) m/c language code of clrscr( ) m/c language code of printf( ) LLiinnkkeerr Executable code
  • 19. Your wish # include ”goto.c” # include goto.c C : TC WS4 . . WORKS INCLUDE INCLUDE DIRECTORIES LIBRARY DIRECTORIES C: TC INCLUDE C: TC LIB C: TC WORKS C: TC OUTPUT DIRECTORY SOURCE DIRECTORIES