function parameter

Function Declaration Or Prototype

Before a function can be used, it must have first been declared. The function declaration, or prototype, tells the compiler how many parameters the function takes, the data type of each parameter, and the data type of the return value for the function.

#include <iostream.h>
#include <conio.h>
#pragma hdrstop
int multiply(int, int);
void showResult(int);

int main(int argc, char **argv)
 {
 int x, y, result;
 cout << endl << “Enter the first value: “;
 cin >> x;
 cout << “Enter the second value: “;
 cin >> y;
 result = multiply(x, y);
 showResult(result);
 cout << endl << endl << “Press any key to continue...”;
 getch();
 return 0;
 }

 int multiply(int x, int y)
 {
 return x * y;
 }

 void showResult(int res)
 {
 cout << “The result is: “ << result << endl;
 }

#pragma hdrstop
int multiply(int, int);
void showResult(int);

int main(int argc, char **argv)
 {
 int x, y, result;
 cout << endl << “Enter the first value: “;
 cin >> x;
 cout << “Enter the second value: “;
 cin >> y;
 result = multiply(x, y);
 showResult(result);
 cout << endl << endl << “Press any key to continue...”;
 getch();
 return 0;
 }

 int multiply(int x, int y)
 {
 return x * y;
 }

 void showResult(int res)
 {
 cout << “The result is: “ << result << endl;
 }

Leave a Comment

Your email address will not be published. Required fields are marked *