Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
1.50/5 (5 votes)
See more:
can u give me example on calling function and called function
Posted
Comments
Sandeep Mewara 23-Jun-12 9:34am    
Not sure on what are you exactly trying to ask here. Please elaborate.

Simple:

Calling function:

int res = Calc(a, b);

Called Function:

public int Calc(int a, int b)
{
return a + b;
}
 
Share this answer
 
private void Form2_Load(object sender, EventArgs e)
{
MsgBox();
}

private void MsgBox()
{
MessageBox.Show("Test");
}
 
Share this answer
 
If you need to know about what is function/method in C# and how to call a method check this tutorial[^]

I'm adding another resource related to C# methods. Check this[^]

And it is better if you can read about Anonymous Functions in C#[^]
 
Share this answer
 
// table.cpp
// demonstrates simple function
#include <iostream>
using namespace std;
void starline(); //function declaration
// (prototype)
int main()
{
starline(); //call to function
cout << “Data type Range” << endl;
starline(); //call to function
cout << “char -128 to 127” << endl
<< “short -32,768 to 32,767” << endl
<< “int System dependent” << endl
<< “long -2,147,483,648 to 2,147,483,647” << endl;
starline(); //call to function
return 0;
}
//--------------------------------------------------------------
// starline()
// function definition
void starline() //function declarator
{
for(int j=0; j<45; j++) //function body
cout << ‘*’;
cout << endl;
}
The output from the program looks like this:
*********************************************
Data type Range
*********************************************
char -128 to 127
short -32,768 to 32,767
int System dependent
long -2,147,483,648 to 2,147,483,647
*********************************************
The program consists of two functions: main() and starline(). You’ve already seen many programs that use main() alone. What other components are necessary to add a function to the program? There are three: the function declaration, the calls to the function, and the function definition.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900