Create two classes: `Rectangle` (private `width`) and `Square` (private `side`). Define a global friend function `void compareArea(Rectangle r, Square s)` for both classes that compares their areas (`width*width` for Rectangle, `side*side` for Square). Print ‘Rectangle is larger’, ‘Square is larger’, or ‘Equal’. Read two integers (width, side), create both objects, and compare them.
Two space-separated integers (width then side).
Print the comparison result.
Width and side >= 0
5 4
Rectangle is larger
A single global friend function can be declared as a friend inside multiple different classes, bridging their private scopes.
#include <iostream>
class Square; // Forward declaration
class Rectangle {
// Define private members, constructor, and friend declaration
};
class Square {
// Define private members, constructor, and friend declaration
};
// Implement compareArea here
int main() {
// Read inputs, create objects, and call compareArea
return 0;
}Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used