//This tut contains Functions and Functions Prototypes
#include<iostream>
using namespace std;
// Function prototype
// type function-name (arguments);
// int sum(int a, int b); //--> Acceptable
// int sum(int a, b); //--> Not Acceptable
int sum(int, int); //--> Acceptable
// void g(void); //--> Acceptable
void g(); //--> Acceptable
int sub(int a,int b){
int c=a-b;
return c;
}
int main(){
int num1, num2;
cout<<"Enter first number :"<<endl;
cin>>num1;
cout<<"Enter second number:"<<endl;
cin>>num2;
// num1 and num2 are actual parameters
cout<<"The subtraction is :"<<sub(num1, num2)<<endl;
cout<<"The sum is :"<<sum(num1,num2)<<endl;
g();
return 0;
}
int sum(int a, int b){
// Formal Parameters a and b will be taking values from actual parameters num1 and num2.
int c = a+b;
return c;
}
void g(){
cout<<"\nHi, Have a nice day.";
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.