Function Prototypes In C++
Function Prototypes In C++
There are mainly four types of function prototypes. Function prototype means how you can write a function or you can say the way of writing any function in a program -
#include <iostream>
using namespace std;
/*FUNCTION PROTOTYPES
1 - With argument & return
2 - With argument & no return
3 - With return & no argument
4 - No reutrn & no argument
*/
// Here I will show you a function
// which can be represented in all prototypes
// 1 - With argument & return
int square(int num)
{
return num*num;
}
// 2 - With argument & no return
void square2(int num)
{
cout<<"Square Is: "<<num*num<<endl;
}
// 3 - With return & no argument
int square3()
{
int num;
cout<<"Enter The Number: "<<endl;
cin>>num;
return num*num;
}
// 4 - No reutrn & no argument
void square4()
{
int num;
cout<<"Enter The Number: "<<endl;
cin>>num;
cout<<"Square Is: "<<num*num<<endl;
}
void main()
{
}
Comments
Post a Comment