|
|
| Programming Get help with creating your scripts/software or help others. Discuss anything relating to programming. Includes PHP, Perl, C++, ColdFusion, etc. |

03-18-2011, 05:32 PM
|
|
Senior Member
|
|
Join Date: Feb 2011
Posts: 134
|
|
Role of Functions
What is role of functions in C++ language?
|

04-03-2011, 04:41 PM
|
|
Junior Member
|
|
Join Date: Mar 2011
Location: Halifax NS
Posts: 15
|
|
|
Functions perform functions. They allow code re-use.
|

04-07-2011, 10:49 AM
|
|
Junior Member
|
|
Join Date: Apr 2011
Posts: 19
|
|
|
So function in a C program has some properties discussed below.
•Every function has a unique name. This name is used to call function from “main()” function. A function can be called from within another function.
•A function is independent and it can perform its task without intervention from or interfering with other parts of the program.
•A function performs a specific task. A task is a distinct job that your program must perform as a part of its overall operation, such as adding two or more integer, sorting an array into numerical order, or calculating a cube root etc.
•A function returns a value to the calling program. This is optional and depends upon the task your function is going to accomplish. Suppose you want to just show few lines through function then it is not necessary to return a value. But if you are calculating area of rectangle and wanted to use result somewhere in program then you have to send back (return) value to the calling function.
|

04-11-2011, 05:21 AM
|
|
Member
|
|
Join Date: Mar 2011
Posts: 54
|
|
|
Function is play vital role to promote the site.With the help function we can promote our site and link.We can introduce himself and his site.
|

04-11-2011, 06:47 AM
|
|
Member
|
|
Join Date: Mar 2011
Posts: 40
|
|
|
function is define class . function is function name
|

05-12-2011, 12:18 PM
|
|
Member
|
|
Join Date: Apr 2011
Posts: 39
|
|
|
Function is used to write code which is use many times in code. Means when we use function in coding then no need to write same code again and again . you have to just call that function whenever yo u need .
|

05-13-2011, 05:38 AM
|
 |
Member
|
|
Join Date: May 2011
Location: Earth
Posts: 48
|
|
Use function we can structure...
Use function we can structure our program in a more modular method, access all the probable to planned programming be able to offer us in C++.
Example of the function
-----------------------
// function example
#include <iostream>
using namespace std;
int addition (int a, int b)
{
int r;
r=a+b;
return (r);
}
int main ()
{
int z;
z = addition (5,3);
cout << "The result is " << z;
return 0;
}
Output is
8

|

06-13-2011, 07:59 AM
|
|
Member
|
|
Join Date: May 2011
Posts: 70
|
|
|
If you bethink the syntax of a action declaration:
type name ( argument1, argument2 ...) statement
you will see that the declaration begins with a type, that is the type of the function itself.
Imagine that we want to make a function just to show a message on the screen. We do not need it to return any value.
|

06-13-2011, 08:33 AM
|
 |
Member
|
|
Join Date: May 2011
Location: Earth
Posts: 48
|
|
Quote:
Originally Posted by danieljames123
If you bethink the syntax of a action declaration:
type name ( argument1, argument2 ...) statement
you will see that the declaration begins with a type, that is the type of the function itself.
Imagine that we want to make a function just to show a message on the screen. We do not need it to return any value.
|
Thanks a lot for the replay..@jenny3103
A function is independent and it can perform its task without intervention from or interfering with other parts of the program.
|

06-14-2011, 08:17 AM
|
|
Member
|
|
Join Date: May 2011
Posts: 70
|
|
|
Its ok. I always ready to help. I am feel good when I helped anyone.
|

07-04-2011, 12:58 PM
|
|
Member
|
|
Join Date: Jun 2011
Posts: 80
|
|
|
Function basically avoids the re usability of the code. its a block of statement which are to be implemented when ever necessary.
|

07-15-2011, 01:32 PM
|
|
Senior Member
|
|
Join Date: Jul 2011
Posts: 111
|
|
|
function can used the recall the method every where ,according the c++ ,because the C++ is OOPs concept follow .
|

08-23-2011, 10:02 AM
|
|
Junior Member
|
|
Join Date: Aug 2011
Location: USA
Posts: 26
|
|
|
A function is a group of statements that is executed when it is called from some point of the program. Using functions we can structure our programs more modular, access to all the potential that we can provide structured programming in C + +.
|

09-23-2011, 05:29 PM
|
|
Senior Member
|
|
Join Date: Sep 2011
Posts: 306
|
|
|
Using functions we can structure our programs in a more modular way, accessing all the potential that structured programming can offer to us in C++.
A function is a group of statements that is executed when it is called from some point of the program. The following is its format:
type name ( parameter1, parameter2, ...) { statements }
where:
* type is the data type specifier of the data returned by the function.
* name is the identifier by which it will be possible to call the function.
* parameters (as many as needed): Each parameter consists of a data type specifier followed by an identifier, like any regular variable declaration (for example: int x) and which acts within the function as a regular local variable. They allow to pass arguments to the function when it is called. The different parameters are separated by commas.
* statements is the function's body. It is a block of statements surrounded by braces { }.
|

10-18-2011, 07:53 AM
|
|
Senior Member
|
|
Join Date: Sep 2011
Posts: 166
|
|
|
A function is a block of code that has a name and it has a property that it is reusable i.e. it can be executed from as many different points in a C Program as required.
|

10-18-2011, 08:06 AM
|
|
Senior Member
|
|
Join Date: May 2011
Posts: 392
|
|
|
If anyone need complete information about C++.
Please use this website you have good idea about C++.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 04:23 AM.
|