Multilevel Inheritance Structure

Medium Single & Multilevel Inheritance
Solve in Playground →

Problem Statement

Define `A`, `B` (inherits `A`), and `C` (inherits `B`). `A` has public `int x`, `B` has public `int y`, and `C` has public `int z`. In `main()`, instantiate `C`, read 3 integers into `x`, `y`, and `z` via the `C` object, and print “Sum: [sum]”.

Input Format

Three space-separated integers.

Output Format

Print the sum of the three inherited integers.

Constraints

-1000 <= x, y, z <= 1000

Sample Input

10 20 30

Sample Output

Sum: 60

Explanation

In multilevel inheritance, traits are passed down sequentially. `C` inherits `y` from `B`, and `x` from `A` through `B`.

Starter Code

#include <iostream>

class A {
public:
    // Define x
};

class B {
    // Inherit A, define y
};

class C {
    // Inherit B, define z
};

int main() {
    // Instantiate C, read inputs, and print the sum
    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