programplug Logo




C++ Function


A function is a self-contained block of statements that perform a specific task. A function can be call many times.By using function we can divide a code into the function.Function provides modularity and code reusability.


Types Of Functions


There are two types of functions-

» Library Functions
» User-defined functions


Library Functions

They Are Pre Defined header files such as ceil(), cos(), exp(), etc.

User-defined functions

These functions are declared by the user depends on their requirements.It reduces complexity of a big program.


function-name(parameters)
{
  statement;
}

User-defined functions can be declared in four types-

(1) Without return - Without argument

void main(void)
{
  statement;
}

(2) Without return - With argument

void main(int a)
{
  statement;
}

(3) With return - Without argument

int main()
{
  statement;
  return();
}

(4) With return - With argument

int main(int a,int b,....)
{
  statement;
  return(a,b,...);
}

#include 
void welcome()
{    
cout<<"Hello World";    
}    
void main()
{        
welcome();     //calling a function    
welcome();    //calling a function second time  
}   

Output:
Hello World
Hello World







Our Services

Developing Cheapest Websites
Offer Digital Marketing
Provide College Projects
Attractive Website Developing
Summer Training,Industrial Training
SCO,SMO

Contact Us

Dehradun Uttarakhand India
www.programplug.com
info@programplug.com
000000000

Other Link

About Us

Contact Us

Disclaimer

Privacy Policy