Upon calling the function display the average determined by the user-defined function
#include<iostream>
using namespace std;
float average(int first, int second){
return (first + second) / 2;
}
int main(){
int first, second;
cout<<"Enter the first element: \t"<<endl;
cin>>first;
cout<<"Enter the second element: \t"<<endl;
cin>>second;
cout<<"The first element is: \t"<<first<<"\nThe second element is:\t"<<second<<endl;
cout<<"The average is:\t"<<average(first,second);
}
Comments
Leave a comment