4 Types of Function

#include <iostream>
using namespace std;

/*

//Witout return without Par
void Sum(){
//input
//proccess
/output
int a,b,c;
cout<<"Please Input 2 Number:\n";
cin>>a>>b;
c=a+b;
cout<<"Result="<<c;
}




int main(){

//=====1===
Sum();//Call
}

*/
//====================2================
/*
//Witout return with Par

void Sum(int a,int b){
//procces
//output
int c;
c=a+b;
cout<<"Result="<<c;
}


int main(){

//Input
int a,b;
cout<<"Please Input 2 Number:\n";
cin>>a>>b;
//=====2===
Sum(a,b);//Call
}
*/

//=============3============
//with return without par
/*

int Sum(){
//input
int a,b,c;
cout<<"Please Input 2 number\n";
cin>>a>>b;
//proccess
c=a+b;
return c;
}

int main(){
//output
int c;
c=Sum();
cout<<"Result="<<c;
}

*/

//=============4===========
//with return with par

int Sum(int a,int b){
//Proccess
return (a+b);
}

int main(){
int a,b,c;
//Input
cout<<"Please Input 2 Number\n";
cin>>a>>b;
c=Sum(a,b);
//Output
cout<<"Result="<<c;
return 0;
}

Comments

Popular posts from this blog

Dynamic Memory2

Template

MultiLevel