Begin3. The sides of the rectangle \(a\) and \(b\) are given. Find its area \(S = a \cdot b\) and the perimeter \(P = 2 \cdot (a + b)\).

Solution in Python 3:

import random

a = random.randrange(1,10)
print("Sides of the rectangle:")
print("a = ", a)
b = random.randrange(1,10)
print("b = ", b)
S = a * b
print("Area of the rectangle S = ", S)
P = 2 * (a + b)
print("Perimeter of the rectangle P = ", P)

Solution in C++:

#include<iostream>
using namespace std;
int main(){
double a, b, s, p;
cout << "Enter the side A: ";
cin >> a;
cout << "Enter the side B: ";
cin >> b;
s = a*b;
p = (a+b)*2;
cout << "Area: " << s << endl;
cout << "Perimeter: " << p;
return 0;
}