The document discusses functions and static variables in C++. It covers topics like:
- Creating functions, invoking functions, and passing arguments to functions.
- Determining the scope of local and global variables.
- Understanding the differences between pass-by-value and pass-by-reference.
- Using function overloading and dealing with ambiguous overloading.
- Using function prototypes for declaring function headers.
- Knowing how to use default arguments.
- Static variables.
Call by value or call by reference in C++Sachin Yadav
Call by value means passing the value directly to a function. The called function uses the value in a local variable; any changes to it DO NOT affect the source variable. In call by value method, the called function creates its own copies of original values sent to it. Any changes, that are made, occur on the function’s copy of values and are not reflected back to the calling function.
Call by value or call by reference in C++Sachin Yadav
Call by value means passing the value directly to a function. The called function uses the value in a local variable; any changes to it DO NOT affect the source variable. In call by value method, the called function creates its own copies of original values sent to it. Any changes, that are made, occur on the function’s copy of values and are not reflected back to the calling function.
Types of C++ functions:
Standard functions
User-defined functions
C++ function structure
Function signature
Function body
Declaring and Implementing C++ functions
If any class have multiple functions with same names but different parameters then they are said to be overloaded. Function overloading allows you to use the same name for different functions, to perform, either same or different functions in the same class.
If you have to perform one single operation but with different number or types of arguments, then you can simply overload the function.
(video of these slides available here http://fsharpforfunandprofit.com/fppatterns/)
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID.
The functional programming community has design patterns and principles as well.
This talk will provide an overview of some of these, and present some demonstrations of FP design in practice.
hey this is Rupendra choudhary..!! i shared my "c" lang ppt..!!! u just goto that ppt if u r in deep with "c" ..!!! i create after i hv played a much with "c"..(sorry bt ppt is slightly disturbd may be due to unsupportable msppt2010 by slideshare)...find me on rupendrachoudhary1990@gmail.com or https://rupendrachoudhary.wordpress.com
This is continuation of the slide Advanced C part 1. In part 1 you learnt about fundamentals of C - How to build an algorithm, operators. In this module - Advanced C part 2 you will be learning about functions, pointers and standard Input Output functions. This slide will help you to move a further ahead in Advanced C and gain deeper knowledge on it.
Types of C++ functions:
Standard functions
User-defined functions
C++ function structure
Function signature
Function body
Declaring and Implementing C++ functions
If any class have multiple functions with same names but different parameters then they are said to be overloaded. Function overloading allows you to use the same name for different functions, to perform, either same or different functions in the same class.
If you have to perform one single operation but with different number or types of arguments, then you can simply overload the function.
(video of these slides available here http://fsharpforfunandprofit.com/fppatterns/)
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID.
The functional programming community has design patterns and principles as well.
This talk will provide an overview of some of these, and present some demonstrations of FP design in practice.
hey this is Rupendra choudhary..!! i shared my "c" lang ppt..!!! u just goto that ppt if u r in deep with "c" ..!!! i create after i hv played a much with "c"..(sorry bt ppt is slightly disturbd may be due to unsupportable msppt2010 by slideshare)...find me on rupendrachoudhary1990@gmail.com or https://rupendrachoudhary.wordpress.com
This is continuation of the slide Advanced C part 1. In part 1 you learnt about fundamentals of C - How to build an algorithm, operators. In this module - Advanced C part 2 you will be learning about functions, pointers and standard Input Output functions. This slide will help you to move a further ahead in Advanced C and gain deeper knowledge on it.
It tells about functions in C++,Types,Use,prototype,declaration,Arguments etc
function with
A function with no parameter and no return value
A function with parameter and no return value
A function with parameter and return value
A function without parameter and return value
Call by value and address
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Accelerate your Kubernetes clusters with Varnish Caching
Cs1123 8 functions
1. Functions and Static Variables
(CS1123)
By
Dr. Muhammad Aleem,
Department of Computer Science,
Mohammad Ali Jinnah University, Islamabad
2. Lecture Objectives
• To create functions, invoke functions, and pass
arguments to a function
• To determine the scope of local and global variables
• To understand the differences between pass-by-
value and pass-by-reference
• To use function overloading and understand
ambiguous overloading
• To use function prototypes for declaring function
headers
• To know how to use default arguments
• Static Variables
3. Functions in C++
• Experience has shown that the best way to develop
and maintain large programs is to construct it from
smaller pieces (modules)
• This technique Called “Divide and Conquer”
main()
{
-----
-----
-----
-----
.
.
.
----
-----
-----
return 0;
}
Bad Development Approach
Easier To >>
Design
Build
Debug
Extend
Modify
Understand
Reuse
Wise Development Approach
main()
{
-----
----
}
function f1()
{
---
---
}
function f2()
{
---
---
}
4. Functions in C++(Cont.)
• In C++ modules Known as Functions & Classes
• Programs may use new and “prepackaged” or built-
in modules
–New: programmer-defined functions and classes
–Prepackaged: from the standard library
5. About Functions in C++
• Functions invoked by a function–call-statement which
consist of it’s name and information it needs
(arguments)
• Boss To Worker Analogy:
Main
Boss
Function A Function B
Function Z
Worker
Worker
Function B2Function B1
Worker
Sub-Worker Sub-Worker
Note: usually main( ) Calls other
functions, but other functions can call
each other
6. Calling Function
• Function calls:
- Provide function name and arguments (data):
Function performs operations and
Function returns results
7. Calling Functions
• Functions calling (Syntax):
<function name> (<argument list>);
E.g.,
FunctionName( );
or
FunctionName(argument1);
or
FunctionName(argument1, argument2, …);
8. Calling Functions
•Examples (built-in, and user-defined functions)
int n = getPIValue( ) ; //Takes no argument
cout << sqrt(9); //Takes one argument, returns square-root
cout<<pow(2,3); //Calculates 2 power 3
cout<<SumValues(myArray); //Returns sum of the array
A user-defined function
A user-defined function
9. Function Definition
• Syntax format for function definition
returned-value-type function-name (parameter-list)
{
Declarations of local variables and Statements;
…
}
– Parameter list
• Comma separated list of arguments
–Data type needed for each argument
• If no arguments leave blank
– Return-value-type
• Data type of result returned (use void if nothing will
be returned)
10. Function Prototype
Before a function is called, it must be declared first.
Functions cannot be defined inside other functions
A function prototype is a function declaration without
implementation (the implementation can be given
later in the program).
int multiplyTwoNums(int,int);
A Function prototype (declaration
without implementation)
11. Function Prototype (cont.)
Before actual implementation of a function, a function
prototype can be used.
Why it is needed?
It is required to declare a function prototype before
the function is called.
12. Function Prototype (cont.)
void main()
{
int sum = AddTwoNumbers(3,5);
cout<<sum;
}
int AddTwoNumbers(int a, int b)
{
int sum = a+b;
return sum;
}
Error: Un-defined function
13. Function Prototype (cont.)
int AddTwoNumbers(int a, int b)
{
int sum = a+b;
return sum;
}
void main()
{
int sum = AddTwoNumbers(3,5);
cout<<sum;
}
int AddTwoNumbers(int, int);
void main()
{
int sum = AddTwoNumbers(3,5);
cout<<sum;
}
int AddTwoNumbers(int a, int b)
{
int sum = a+b;
return sum;
}
Solution-1 Solution-2
14. Function signature and Parameters
Function signature is the combination of the
function name and the parameter list.
Variables defined in the function header are known
as formal parameters.
When a function is invoked, you pass a value to the
parameter. This value is referred to as actual
parameter or argument.
15. A function may return a value:
returnValueType is the data type of the value
the function returns.
If function does not return a value, the
returnValueType is the keyword void.
For example, the returnValueType in the main
function is void.
c
Function’s return values
16. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
17. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
i is now 5
18. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
j is now 2
19. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
Call max(5, 2)
20. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
Now num1=5 num2=2
21. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
A new variable result will be created (local to the max function)
22. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
5 > 2 true condition
23. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
result = 5
24. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
return 5
25. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
k = 5
26. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
Display “The maximum between 5 and 2 is 5”
27. Calling Functions
int max(int,int);
int main()
{
int i = 5;
int j = 2;
int k = max(i, j);
cout << "The maximum between "
<< i << " and " + j + " is "
<< k;
return 0;
}
int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Pass the value i
Pass the value j
c
main function ends
29. Formal parameters and variables declared within
a function body are local to that function:
Cannot be accessed outside of that function
int add(int A, int B)
{
int sum = a+b;
return sum;
}
c
Variables scope
A
B
sum
Memory (for function add)
30. Gobal variables with same name:
int sum=55;
void main()
{
…
}
void display()
{
int sum = 66;
cout<<sum; // Display 66
}
c
Variables scope
55
Global Memory
sum
66
Memory (for function display)
sum
31. Gobal variables with same name:
int sum=55;
void main()
{
…
}
void display()
{
int sum = 66;
cout<<::sum; // Display 55
}
c
Variables scope
55
Global Memory
sum
66
Memory (for function display)
sum
32. Calling Functions
• Three ways to pass arguments to function
1. Pass-by-value
2. Pass-by-reference with reference arguments
3. Pass-by-reference with pointer arguments
c
33. 1. Pass by value – Example
void func (int num)
{
cout<<"num = "<<num<<endl;
num = 10;
cout<<"num = "<<num<<endl;
}
void main()
{
int n = 5;
cout<<"Before function call: n = "<<n<<endl;
func(n);
cout<<"After function call: n = "<<n<<endl;
}
c
34. Using Reference Variables with Functions
• To create a second name for a variable in a
program, you can generate an alias, or an alternate
name
• In C++ a variable that acts as an alias for another
variable is called a reference variable, or simply a
reference
• Arguments passed to function using reference
arguments:
c
35. 2. Pass By Reference
You can use a reference variable as a parameter in a
function and pass a regular variable to invoke the
function.
The parameter becomes an alias for the original
variable. This is known as pass-by-reference.
When you change the value through the reference
variable, the original value is actually changed.
c
36. 2. Pass by Reference – Example
void func(int &num)
{
cout<<"num = "<<num<<endl;
num = 10;
cout<<"num = "<<num<<endl;
}
void main()
{
int n = 5;
cout<<"Before function call: n = "<<n<<endl;
func(n);
cout<<"After function call: n = "<<n<<endl;
}
c
num refers to variable
n (in main function)
37. 2. Pass by Reference - Example
• Swap two variable using a Pass-By reference
c
38. Passing an Array to a Function
• When passing an array to a function, we need to tell
the compiler what the type of the array is and give
it a variable name, similar to an array declaration
float a[]
• We don’t want to specify the size so function can
work with different sized arrays.
• Size comes in as a second parameter
This would be a formal parameter
c
39. Passing an Array to a Function
int Display(int data[], int N)
{ int k;
cout<<“Array contains”<<endl;
for (k=0; k<N; k++)
cout<<data[k]<<“ “;
cout<<endl;
}
int main()
{
int a[4] = { 11, 33, 55, 77 };
Display(a, 4);
}
An int array
parameter
of unknown size
The size of
the array
The array
argument, no []
c
40. 43
Passing an Array to a Function
#include <iostream.h>
int sum(int data[], int n); //PROTOTYPE
void main()
{
int a[] = { 11, 33, 55, 77 };
int size = sizeof(a)/sizeof(int);
cout << "sum(a,size) = " << sum(a,size) << endl;
}
int sum(int data[], int n)
{
int sum=0;
for (int i=0; i<n;i++)
sum += data[i];
return sum;
}
An int array
parameter
of unknown size
The size of the array
The array argument, no []
c
41. Arrays are always Pass By Reference
• Arrays are automatically passed by reference.
• Do not use &.
• If the function modifies the array, it is also modified in
the calling environment.
//Following function sets the values of an array to 0
void Zero(int arr[], int N)
{
for (int k=0; k<N; k++)
arr[k]=0;
}
c
42. • Function overloading
– Functions with same name and different
parameters
– Should perform similar tasks:
• i.e., function to square ints and function to
square floats
Function Overloading
c
int square(int x)
{
return (x * x);
}
float square(float x)
{
return (x * x);
}
43. • At call-time C++ complier selects the proper
function by examining the number, type and
order of the parameters
Function Overloading
c
44. void print(int i)
{ cout << " Here is int " << i << endl; }
void print(double f)
{ cout << " Here is float " << f << endl; }
void print(char* c)
{ cout << " Here is char* " << c << endl; }
int main()
{ print(10); print(10.10); print("ten"); }
Function Overloading
c
45. void main()
{
int x = 20, y = 15;
int z = Test(x, y);
cout<<x<<" "<<y<<" "<<z;
}
Class Exercise 1 - Find the output
Ce
int Test(int &a, int b)
{
if(a >= 5)
{
a++;
b--;
return b;
}
else
{
--b;
--a;
return b;
}
}
47. • Write a program that calculates the area of a rectangle
(width*length). The program should be based on the
following functions:
– int getLength( )
– int getWidth( )
– int CalculateArea( )
– void DisplayArea( )
Class Exercise-2
c
48. • Write a C++ program that has a function called
zeroSmaller( ) that is passed two int arguments by
reference and then sets the smaller of the two numbers
to 0.
Class Exercise-3
c
49. • Write a function called swap() that interchanges two int
values passed to it by the calling program. (Note that this
function swaps the values of the variables in the calling
program, i.e., the original. You’ll need to decide how to
pass the arguments. Create a main() program to exercise
the function.
Class Exercise-4
c
50. • Write a function that, when you call it, displays a
message telling how many times it has been called: “I
have been called 3 times”, for instance. Write a main()
program that ask the user to call the function, if the user
presses ‘y’ the function is called otherwise if ‘n’ is
pressed the program terminates.
Class Exercise-5
c
52. Scope
• Different levels of scope:
1. Function scope
2. block scope
3. File scope
4. Class scope
Local variables
Global variables
53. Lifetime of Variables
• Local Variables (function and block scope)
have lifetime of the function or block
• Global variable (having file level scope) has
lifetime until the end of program
• Examples…
54. Static Variables
Static Variables
• Is created at the start of program execution
• A static variable has scope of local variable
• But has lifetime of global variables
• Therefore, static variables retain their contents or
values (until the program ends)
• If not initialized, it is assigned value 0 (automatically
by the compiler)
55. Static Variables - Example
• In the following example, the static variable sum is
initialized to 1
static int sum = 1;
• Initialization takes place only once.
• If declaration in a user-defined function:
First time the function is called, the variable sum is
initialized to 1.
Next time the function (containing the above
declaration) is executed But sum is not reset to 1.
56. • Write a function that, when you call it, displays a
message telling how many times it has been called: “I
have been called 3 times”, for instance. Write a main()
program that ask the user to call the function, if the user
presses ‘y’ the function is called otherwise if ‘n’ is
pressed the program terminates.
Class Exercise-5 (Using Static Variable)
c