The area of a rectangle is the rectangle`s length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the users which rectangle has the greater area. . Solve the task using the conditional Operators.
code:#include <iostream>
using namespace std;
int main()
{
int length_1;
int length_2;
int width_1;
int width_2;
int area_1;
int area_2;
cout << "Enter value of length 1:";
cin >> length_1;
cout << "Enter value of length 2:";
cin >> length_2;
cout << "Enter value of width 1:";
cin >> width_1;
cout << "Enter value of width 2:";
cin >> width_2;
area_1 = length_1*width_1;
area_2 = length_2*width_2;
int x = (area_1 > area_2) ? area_1 : area_2;
cout << x;
return 0;
}
output :Enter value of length 1:2
Enter value of length 2:2
Enter value of width 1:3
Enter value of width 2:3
6
0 Comments