SlideShare a Scribd company logo
1 of 44
table of content
•Introduction
•Historical development of c
•C tokens
•Identifiers
•Keyword
•Data type
•Constants and variable
•Variable
•C instruction
•Type of operation.
•if else statement
•switch statement
•looping
•array
•storage classes
•type of function call in c
•function
•pointer
•structure
Declaring an Array
Like any other variable, arrays must be declared before they are used.
General form of array declaration is,
data-type variable-name[size];
for example :int arr[10];
Here int is the data type, arr is the name of the array and 10 is the size of array. It means
array arr can only contain 10 elements of int type. Index of an array starts from 0 to size-1
i.e first element of arr array will be stored at arr[0] address and last element will occupy
arr[9].
Two dimensional Arrays
C language supports multidimensional arrays. The simplest form of the
multidimensional array is the two-dimensional array.
Two-dimensional array is declared as follows,
type array-name[row-size][column-size] Example : int a[3][4];
The above array can also be declared and initialized together. Such as,
Storage classes
In C language, each variable has a storage class which decides
scope, visibility and lifetime of that variable. The following
storage classes are most oftenly used in C programming,
Automatic variables
A variable declared inside a function without any storage class specification,
is by default an automatic variable. They are created when a function is
called and are destroyed automatically when the function exits. Automatic
variables can also be called local variables because they are local to a
function. By default they are assigned garbage value by the compiled
External or Global variable
A variable that is declared outside any function is a Global variable. Global variables remain
available throughout the entire program. One important thing to remember about global
variable is that their values can be changed by any function in the program.
int number;
void main()
{
number=10;
}
fun1()
{
number=20;
}
fun2()
{number=30;
}Here the global variable number is available to all three functions.
Static variables
A static variable tells the compiler to persist the variable until the end of program.
Instead of creating and destroying a variable every time when it comes into and goes
out of scope, static is initialized only once and remains into existence till the end of
program. A static variable can either be internal or external depending upon the place of
declaraction. Scope of internal static variable remains inside the function in which it is
defined.
External static
variables remain restricted to scope of file in each they are declared.
They are assigned 0 (zero) as default value by the compiler.
void test(); //Function declaration (discussed in next topic)
main()
{
test();
test();
test();
}
void test()
{
static int a = 0; //Static variable
a = a+1;
printf("%dt",a);
}
output :1 2 3
Register variable
Register variable inform the compiler to store the variable in
register instead of memory. Register variable has faster access
than normal variable. Frequently used variables are kept in register.
Only few variables can be placed inside register..
Syntax :
register int number;
Types of Function calls in C
Functions are called by their names. If the function is without argument, it can be called directly
using its name. But for functions with arguments, we have two ways to call them,
1.Call by Value
2.Call by Reference
Call by Value
In this calling technique we pass the values of arguments which are stored or copied into the formal parameters
of functions. Hence, the original values are unchanged only the parameters inside function changes.
In this case the actual variable x is not changed, because we pass argument by value, hence a
copy of x is passed, which is changed, and that copied value is destroyed as the function
ends(goes out of scope). So the variable x inside main() still has a value 10.
Call by Reference
In this we pass the address of the variable as arguments. In this
case the formal parameter can be taken as a reference or a
pointer, in both the case they will change the values of the
original variable.
void calc
(int *p);
int main()
{
int x = 10;
calc(&x); // passing address of x as argument
printf("%d", x);
}
void calc(int *p)
{
*p = *p + 10;
}
Output : 20
C language presentation
C language presentation
C language presentation

More Related Content

What's hot (20)

Amit user defined functions xi (2)
Amit  user defined functions xi (2)Amit  user defined functions xi (2)
Amit user defined functions xi (2)
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
Method parameters in c#
Method parameters in c#Method parameters in c#
Method parameters in c#
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Function & Recursion
Function & RecursionFunction & Recursion
Function & Recursion
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
Function in c
Function in cFunction in c
Function in c
 
user defined function
user defined functionuser defined function
user defined function
 
Types of function call
Types of function callTypes of function call
Types of function call
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Function in C Language
Function in C Language Function in C Language
Function in C Language
 
Functions in C
Functions in CFunctions in C
Functions in C
 
predefined and user defined functions
predefined and user defined functionspredefined and user defined functions
predefined and user defined functions
 
Pre defined Functions in C
Pre defined Functions in CPre defined Functions in C
Pre defined Functions in C
 
Chap 9(functions)
Chap 9(functions)Chap 9(functions)
Chap 9(functions)
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions in C
 

Viewers also liked

Commercial Building Services_MB-100 Rev D
Commercial Building Services_MB-100 Rev DCommercial Building Services_MB-100 Rev D
Commercial Building Services_MB-100 Rev DGraeme Simmers
 
new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1
new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1
new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1Vishnu R
 
Waterproof &Airproof Garments
Waterproof &Airproof GarmentsWaterproof &Airproof Garments
Waterproof &Airproof GarmentsJotish Roy (BUBT)
 
NON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIA
NON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIANON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIA
NON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIAVishnu R
 
CV DAVID EDWARD FISHER
CV DAVID EDWARD FISHERCV DAVID EDWARD FISHER
CV DAVID EDWARD FISHERDavid Fisher
 

Viewers also liked (6)

Commercial Building Services_MB-100 Rev D
Commercial Building Services_MB-100 Rev DCommercial Building Services_MB-100 Rev D
Commercial Building Services_MB-100 Rev D
 
new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1
new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1
new profile_52.3m_three points_unsplitted-Nonlinear with epoxy-1
 
Waterproof &Airproof Garments
Waterproof &Airproof GarmentsWaterproof &Airproof Garments
Waterproof &Airproof Garments
 
Maboneng Pricint
Maboneng Pricint Maboneng Pricint
Maboneng Pricint
 
NON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIA
NON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIANON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIA
NON LINEAR ANALYSIS OF A HAWT BLADE USING LARGE DEFLECTION CRITERIA
 
CV DAVID EDWARD FISHER
CV DAVID EDWARD FISHERCV DAVID EDWARD FISHER
CV DAVID EDWARD FISHER
 

Similar to C language presentation

Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2Prerna Sharma
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE jatin batra
 
What is storage class
What is storage classWhat is storage class
What is storage classIsha Aggarwal
 
functioninpython-1.pptx
functioninpython-1.pptxfunctioninpython-1.pptx
functioninpython-1.pptxSulekhJangra
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptxRhishav Poudyal
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageJenish Bhavsar
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniquesvalarpink
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 FunctionDeepak Singh
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cppsharvivek
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Rasan Samarasinghe
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptRajasekhar364622
 

Similar to C language presentation (20)

Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
 
Function in C++
Function in C++Function in C++
Function in C++
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
functioninpython-1.pptx
functioninpython-1.pptxfunctioninpython-1.pptx
functioninpython-1.pptx
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C Language
 
C language 3
C language 3C language 3
C language 3
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Functions in C++.pdf
Functions in C++.pdfFunctions in C++.pdf
Functions in C++.pdf
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.ppt
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 
Functions
FunctionsFunctions
Functions
 
Shanks
ShanksShanks
Shanks
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

C language presentation

  • 1.
  • 2. table of content •Introduction •Historical development of c •C tokens •Identifiers •Keyword •Data type •Constants and variable •Variable •C instruction •Type of operation. •if else statement •switch statement •looping •array •storage classes •type of function call in c •function •pointer •structure
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. Declaring an Array Like any other variable, arrays must be declared before they are used. General form of array declaration is, data-type variable-name[size]; for example :int arr[10]; Here int is the data type, arr is the name of the array and 10 is the size of array. It means array arr can only contain 10 elements of int type. Index of an array starts from 0 to size-1 i.e first element of arr array will be stored at arr[0] address and last element will occupy arr[9].
  • 37. Two dimensional Arrays C language supports multidimensional arrays. The simplest form of the multidimensional array is the two-dimensional array. Two-dimensional array is declared as follows, type array-name[row-size][column-size] Example : int a[3][4]; The above array can also be declared and initialized together. Such as,
  • 38. Storage classes In C language, each variable has a storage class which decides scope, visibility and lifetime of that variable. The following storage classes are most oftenly used in C programming, Automatic variables A variable declared inside a function without any storage class specification, is by default an automatic variable. They are created when a function is called and are destroyed automatically when the function exits. Automatic variables can also be called local variables because they are local to a function. By default they are assigned garbage value by the compiled External or Global variable A variable that is declared outside any function is a Global variable. Global variables remain available throughout the entire program. One important thing to remember about global variable is that their values can be changed by any function in the program. int number; void main() { number=10; } fun1() { number=20; } fun2() {number=30; }Here the global variable number is available to all three functions.
  • 39. Static variables A static variable tells the compiler to persist the variable until the end of program. Instead of creating and destroying a variable every time when it comes into and goes out of scope, static is initialized only once and remains into existence till the end of program. A static variable can either be internal or external depending upon the place of declaraction. Scope of internal static variable remains inside the function in which it is defined. External static variables remain restricted to scope of file in each they are declared. They are assigned 0 (zero) as default value by the compiler. void test(); //Function declaration (discussed in next topic) main() { test(); test(); test(); } void test() { static int a = 0; //Static variable a = a+1; printf("%dt",a); } output :1 2 3
  • 40. Register variable Register variable inform the compiler to store the variable in register instead of memory. Register variable has faster access than normal variable. Frequently used variables are kept in register. Only few variables can be placed inside register.. Syntax : register int number; Types of Function calls in C Functions are called by their names. If the function is without argument, it can be called directly using its name. But for functions with arguments, we have two ways to call them, 1.Call by Value 2.Call by Reference Call by Value In this calling technique we pass the values of arguments which are stored or copied into the formal parameters of functions. Hence, the original values are unchanged only the parameters inside function changes. In this case the actual variable x is not changed, because we pass argument by value, hence a copy of x is passed, which is changed, and that copied value is destroyed as the function ends(goes out of scope). So the variable x inside main() still has a value 10.
  • 41. Call by Reference In this we pass the address of the variable as arguments. In this case the formal parameter can be taken as a reference or a pointer, in both the case they will change the values of the original variable. void calc (int *p); int main() { int x = 10; calc(&x); // passing address of x as argument printf("%d", x); } void calc(int *p) { *p = *p + 10; } Output : 20