Need simple help please!!
Hey guys!
Could you please tell me what the difference is between these two programs?
please explain in depth what the first program does step by step...
Code:
// Listing 5.1 - demonstrates the use of function prototypes
#include <iostream.h>
int FindArea(int length, int width)
int main()
{
int lengthOfYard;
int widthOfYard;
int areaOfYard;
cout << "\nHow wide is your yard? ";
cin >> widthOfYard;
cout << "\nHow long is your yard? ";
cin >> lengthOfYard;
areaOfYard= FindArea(lengthOfYard, widthOfYard);
cout << "\nYour yard is ";
cout << areaOfYard;
cout << " square feet\n\n";
return 0;
}
int FindArea(int l, int w)
{
return l * w;
}
I have written the next program my self, same output:
Code:
#include <iostream.h>
#include <stdlib.h>
int main()
{
int l, w, a;
cout << "How wide is your yard?\n";
cin >> w;
cout << "How long is your yard?\n";
cin >> l;
a = (l*w);
cout << "Your yard is:" << a << "Square Feet\n";
system ("pause");
return 0;
}
My code is A LOT shorter that the book's code, and it's even easier to understand!
I dont understand anything about how the first program works, please explain to me!
(I need to proceed to other chapters of the book)