You could either check the value using an if statement, or you can use the
http://www.cplusplus.com/reference/cstdlib/abs/ function, third option would to use types that does not support negative values such as unsigned int or unsigned short.
And you are aware that your code makes perimeter = 0 + 0 + 0 + 0 and area 0 * 0 and then setting them, if they are supposed to be 0 there why dont you skip the arithmetic operations?
Code
int perimeter = length + length + width + width;
int area = length * width;
to
Code
int perimeter;
int area;