Wednesday, 4 December 2013

Function

# include<iostream>
using namespace std;
void dis()
{
cout<<"I am the Display function"<<endl;
}
void main()
{
cout<<"This program is calling the function"<<endl;
dis();
}

In this program,
We will discuss function:-
What is a Function??
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 in a more modular way, accessing all the potential that structured programming can offer to us in C++.

The following is its format:

type name ( parameter1, parameter2, ...)
statements 
}

In the type name,we will enter type such as int float,char etc....!
It is used when the function can return some thing like some value,some character etc.
If we want,a function cannot return some thing then will will put "void",in type.This type is also known as return type
Next,is the function name,It will be any name....In this case,function name is dis!!
Next,Is the parameters,The parameters is the value which we are sending to the function like It may be int,float,char etc.....And there will be as many parameteres as you want in your function.
In this program,we will simply call dis() function and others things I think you got earlier.....!!
Feel free to give suggestions in comment box.......!

0 comments: