SlideShare a Scribd company logo
1 of 14
Download to read offline
By: Shobhit Upadhyay
Functions
 A function is a self contained block of code that performs a
particular task.
 Any C program can be seen as a collection/group of these
functions.
 A functions takes some data as input, perform some
operation on that data and then return a value.
 Any C program must contain at least one function, which is
main().
 There is no limit on the number of functions that might be
present in a C program.
 For ex.
main()
{
message();
printf(“I am in main”);
}
message()
{
printf(“I am in message”);
}
Function Prototype
 All Identifiers in C must be declared before they are used. This is true
for functions as well as variables.
 For functions, the declarations needs to be done before the first call of
the function.
 A function declaration specifies the name, return type, and arguments
of a function. This is also called the function prototype.
 To be a prototype, a function declaration must establish types for the
function’s arguments.
 Having the prototype available before the first use of the function
allows the compiler to check that the correct number and types of
arguments are used in the function call.
 The prototype has the same syntax as the function
definition, except that it is terminated by a semicolon
following the closing parenthesis and therefore has no
body.
 Although, functions that return int values do not require
prototypes, prototypes are recommended.
Function Definition
 General form of any function definition is:
return-type function-name(argument declarations)
{
declarations and statements
}
 Return-type refers to the data type of the value being
returned from the function. If the return type is omitted,
int is assumed.
 The values provided to a function for processing are the
arguments.
 The set of statements between the braces is called as the
function body.
Arguments – Call by Value
 In C, all functions are passed “by value” by default.
 This means that the called function is given the values of its
arguments in temporary variables rather than the originals.
 For ex. main()
{
int a=4,b=5;
sum(a,b);
printf(“Sum = %d”,a+b);
}
sum(int a,int b)
{
a++;
b++;
printf(“Sum = %d”,a+b);
}
Arguments – Call by Reference
 When necessary, it is possible to arrange a function which can modify a
variable in a calling routine.
 The caller must provide the address of the variable to be set (generally, a
pointer to a variable), and the called function must declare the parameter to
be a pointer and access the variable indirectly through it.
 For ex: main()
{
int a=4,b=5;
sum(&a,&b);
printf(“Sum = %d”,a+b);
}
sum(int *a,int *b)
{
(*a)++;
(*b)++;
printf(“Sum = %d”,(*a)+(*b));
}
Recursion
 Recursion defines a function in terms of itself.
 It is a programming technique in which a function calls
itself.
 A recursive function calls itself repeatedly, with different
argument values each time.
 Some argument values cause the recursive method to
return without calling itself. This is the base case.
 Either omitting the base case or writing the recursion step
incorrectly will cause infinite recursion (stack overflow
error).
 Recursion to find the factorial of any number:
int factorial(int x)
{
if(x<=1)
return 1;
else
return(x*factorial(x-1));
}
External Variables
 See the below example:
main()
{
extern int a;
printf(“Value of a = %d”,a);
}
int a=5;
Output: Value of a = 5
Scope Rules
 Example:
int num1 = 100; //Global Scope
static int num2 = 200; //File Scope
int main()
{
int num3 = 300; //Local Scope
if(num2>num1)
{
int i=0; //Block Scope
printf(“Value of i = %dn”,i++);
}
printf(“Value of num1 = %dn”,num1);
printf(“Value of num2 = %dn”,num2);
printf(“Value of num3 = %dn”,num3);
}
Static Variables
 Example:
static int min = 10;
int setmax()
{
static int max = 100;
return ++max;
}
main()
{
min++;
printf(“Value of max = %d”, setmax());
printf(“Value of max = %d”, setmax());
printf(“Value of min = %d”, min);
}
functionsinc-130108032745-phpapp01.pdf

More Related Content

Similar to functionsinc-130108032745-phpapp01.pdf

Similar to functionsinc-130108032745-phpapp01.pdf (20)

User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdf
 
Unit 4.pdf
Unit 4.pdfUnit 4.pdf
Unit 4.pdf
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
unit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfunit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdf
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Functions
FunctionsFunctions
Functions
 
C function
C functionC function
C function
 
Functions
FunctionsFunctions
Functions
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptx
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Ch06
Ch06Ch06
Ch06
 
Amit user defined functions xi (2)
Amit  user defined functions xi (2)Amit  user defined functions xi (2)
Amit user defined functions xi (2)
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 

More from mounikanarra3

travelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdftravelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdfmounikanarra3
 
Space complexity-DAA.pptx
Space complexity-DAA.pptxSpace complexity-DAA.pptx
Space complexity-DAA.pptxmounikanarra3
 
(PAD_5)Dynamic_Programming.ppt
(PAD_5)Dynamic_Programming.ppt(PAD_5)Dynamic_Programming.ppt
(PAD_5)Dynamic_Programming.pptmounikanarra3
 
sequencediagram-150302224029-conversion-gate01 (1).pdf
sequencediagram-150302224029-conversion-gate01 (1).pdfsequencediagram-150302224029-conversion-gate01 (1).pdf
sequencediagram-150302224029-conversion-gate01 (1).pdfmounikanarra3
 
exp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfexp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfmounikanarra3
 
stephenhawkingppt-160402093003.pdf
stephenhawkingppt-160402093003.pdfstephenhawkingppt-160402093003.pdf
stephenhawkingppt-160402093003.pdfmounikanarra3
 

More from mounikanarra3 (15)

unit-2.pdf
unit-2.pdfunit-2.pdf
unit-2.pdf
 
Unit - 4.pptx
Unit - 4.pptxUnit - 4.pptx
Unit - 4.pptx
 
UNIT-1 (4).pdf
UNIT-1 (4).pdfUNIT-1 (4).pdf
UNIT-1 (4).pdf
 
travelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdftravelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdf
 
Space complexity-DAA.pptx
Space complexity-DAA.pptxSpace complexity-DAA.pptx
Space complexity-DAA.pptx
 
EEM MID2.PPT.pptx
EEM MID2.PPT.pptxEEM MID2.PPT.pptx
EEM MID2.PPT.pptx
 
MID2 UML (1).pptx
MID2 UML (1).pptxMID2 UML (1).pptx
MID2 UML (1).pptx
 
(PAD_5)Dynamic_Programming.ppt
(PAD_5)Dynamic_Programming.ppt(PAD_5)Dynamic_Programming.ppt
(PAD_5)Dynamic_Programming.ppt
 
sequencediagram-150302224029-conversion-gate01 (1).pdf
sequencediagram-150302224029-conversion-gate01 (1).pdfsequencediagram-150302224029-conversion-gate01 (1).pdf
sequencediagram-150302224029-conversion-gate01 (1).pdf
 
UML.PPT.pptx
UML.PPT.pptxUML.PPT.pptx
UML.PPT.pptx
 
exp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfexp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdf
 
stephenhawkingppt-160402093003.pdf
stephenhawkingppt-160402093003.pdfstephenhawkingppt-160402093003.pdf
stephenhawkingppt-160402093003.pdf
 
CP-STRING (1).ppt
CP-STRING (1).pptCP-STRING (1).ppt
CP-STRING (1).ppt
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
routing.pptx
routing.pptxrouting.pptx
routing.pptx
 

Recently uploaded

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 

Recently uploaded (20)

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 

functionsinc-130108032745-phpapp01.pdf

  • 2. Functions  A function is a self contained block of code that performs a particular task.  Any C program can be seen as a collection/group of these functions.  A functions takes some data as input, perform some operation on that data and then return a value.  Any C program must contain at least one function, which is main().  There is no limit on the number of functions that might be present in a C program.
  • 3.  For ex. main() { message(); printf(“I am in main”); } message() { printf(“I am in message”); }
  • 4. Function Prototype  All Identifiers in C must be declared before they are used. This is true for functions as well as variables.  For functions, the declarations needs to be done before the first call of the function.  A function declaration specifies the name, return type, and arguments of a function. This is also called the function prototype.  To be a prototype, a function declaration must establish types for the function’s arguments.  Having the prototype available before the first use of the function allows the compiler to check that the correct number and types of arguments are used in the function call.
  • 5.  The prototype has the same syntax as the function definition, except that it is terminated by a semicolon following the closing parenthesis and therefore has no body.  Although, functions that return int values do not require prototypes, prototypes are recommended.
  • 6. Function Definition  General form of any function definition is: return-type function-name(argument declarations) { declarations and statements }  Return-type refers to the data type of the value being returned from the function. If the return type is omitted, int is assumed.  The values provided to a function for processing are the arguments.  The set of statements between the braces is called as the function body.
  • 7. Arguments – Call by Value  In C, all functions are passed “by value” by default.  This means that the called function is given the values of its arguments in temporary variables rather than the originals.  For ex. main() { int a=4,b=5; sum(a,b); printf(“Sum = %d”,a+b); } sum(int a,int b) { a++; b++; printf(“Sum = %d”,a+b); }
  • 8. Arguments – Call by Reference  When necessary, it is possible to arrange a function which can modify a variable in a calling routine.  The caller must provide the address of the variable to be set (generally, a pointer to a variable), and the called function must declare the parameter to be a pointer and access the variable indirectly through it.  For ex: main() { int a=4,b=5; sum(&a,&b); printf(“Sum = %d”,a+b); } sum(int *a,int *b) { (*a)++; (*b)++; printf(“Sum = %d”,(*a)+(*b)); }
  • 9. Recursion  Recursion defines a function in terms of itself.  It is a programming technique in which a function calls itself.  A recursive function calls itself repeatedly, with different argument values each time.  Some argument values cause the recursive method to return without calling itself. This is the base case.  Either omitting the base case or writing the recursion step incorrectly will cause infinite recursion (stack overflow error).
  • 10.  Recursion to find the factorial of any number: int factorial(int x) { if(x<=1) return 1; else return(x*factorial(x-1)); }
  • 11. External Variables  See the below example: main() { extern int a; printf(“Value of a = %d”,a); } int a=5; Output: Value of a = 5
  • 12. Scope Rules  Example: int num1 = 100; //Global Scope static int num2 = 200; //File Scope int main() { int num3 = 300; //Local Scope if(num2>num1) { int i=0; //Block Scope printf(“Value of i = %dn”,i++); } printf(“Value of num1 = %dn”,num1); printf(“Value of num2 = %dn”,num2); printf(“Value of num3 = %dn”,num3); }
  • 13. Static Variables  Example: static int min = 10; int setmax() { static int max = 100; return ++max; } main() { min++; printf(“Value of max = %d”, setmax()); printf(“Value of max = %d”, setmax()); printf(“Value of min = %d”, min); }