Hi, I'm new to c++ and I was practicing with using prototypes and calling functions by writing a simple little program to calculate the perimeter of a rectangle.
#include <iostream>
usingnamespace std;
typedefunsignedlong Ulong; //typedef for easier typing.
typedefunsignedshort Ushort;
Ulong Perimeter(Ushort length, Ushort width); //Prototype.
int main()
{
unsignedshortint l, w, ans;
cout << "Enter the Length of the Rectangle: ";
cin >> l;
cout << "\n";
cout << "Now enter the width: ";
cin >> w;
cout << "\n";
ans = Perimeter(Ushort l,Ushort w); //Where I am getting the error.
cout << "The lenght you selected was: " << l << "\n";
cout << "The width you selected was: " << w << "\n";
cout << "The perimeter the rectangle is: " << ans;
return 0;
}
Ulong Perimeter(Ushort l, Ushort w)
{
return (2*l) + (2*w);
}
On line 18 I am getting the error "expected primary-expression before 'l'" and expected primary-expression before 'w'". Any assistance with correcting my error would be great!