Thread: C++ Functions
View Single Post
Old Jul 13th, 2005, 9:40 PM   #3
Clotters
Programmer
 
Join Date: May 2005
Posts: 60
Rep Power: 4 Clotters is on a distinguished road
Sorry, I'll fx it up for anyone else trying to view it.

//Lsiting 5.1 - demonstrates the use of function prototypes

#include <iostream>

short int roomArea(short int roomLength, short int roomWidth); // prototype

int main()
{
using std::cout;
using std::cin;

int lengthOfRoom;
int widthOfRoom;
int areaOfRoom;

cout << "How wide is your room? ";
cin >> widthOfRoom;
cout << "\nHow long is your room? ";
cin >> lengthOfRoom;

areaOfRoom = Area(lengthOfRoom, edithofRoom)

cout << "\nYour room is ";
cout << areaOfRoom;
cout << " square feet \n";
return0;
}

int Area(int len, int wid)
{
return len * wid;
)

Thanks for the help by the way. Basically by making a prototype, you make promise the compiler you'll define the function later on, but for readability and clarity of script, it isn't a good idea to define the function at this point in the script.

Am I right?
Clotters is offline   Reply With Quote