Parameterized Constructor

Easy Object Lifecycle (Constructors & Destructors)
Solve in Playground →

Problem Statement

Create a `Rectangle` class with integer attributes `width` and `height`. Write a parameterized constructor to initialize them and print ‘W: [width], H: [height]’. Read two integers and instantiate the object.

Input Format

Two space-separated integers.

Output Format

Print the formatted string.

Constraints

Width and height >= 0

Sample Input

5 10

Sample Output

W: 5, H: 10

Explanation

Parameterized constructors allow you to pass specific values during object creation to initialize its attributes.

Starter Code

#include <iostream>

class Rectangle {
public:
    // Define attributes and parameterized constructor
};

int main() {
    int w, h;
    if (std::cin >> w >> h) {
        // Instantiate Rectangle
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

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