Student Class

Easy Classes & Objects
Solve in Playground →

Problem Statement

Write a C++ program defining a `Student` class that computes and displays total marks and percentage from three subject scores.

Input Format

Roll number (int), Name (string), and three floating-point marks.

Output Format

Print student roll, name, total marks, and percentage.

Constraints

Marks between 0 and 100

Sample Input

101 John 80.0 85.5 90.0

Sample Output

Roll: 101, Name: John, Total: 255.50, Percentage: 85.17

Explanation

Demonstrates processing member variables using member functions.

Starter Code

#include <iostream>
#include <string>
#include <iomanip>

class Student {
public:
    int roll;
    std::string name;
    float m1, m2, m3;
    
    void calculate() {
        // Write your code here
    }
};

int main() {
    Student s;
    if (std::cin >> s.roll >> s.name >> s.m1 >> s.m2 >> s.m3) {
        s.calculate();
    }
    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