fork download
  1.  
  2.  
  3. #include <iostream>
  4. #include <graphics.h>
  5.  
  6. using namespace std;
  7.  
  8. void drawBar(int x, int y, int height, char label) {
  9. setfillstyle(SOLID_FILL, LIGHTGREEN);
  10. bar(x, y, x + 50, y - height);
  11. setcolor(BLACK);
  12. rectangle(x, y, x + 50, y - height);
  13. outtextxy(x + 25, y + 10, &label);
  14. }
  15.  
  16. int main() {
  17. int gd = DETECT, gm;
  18. initgraph(&gd, &gm, "");
  19.  
  20. // Display student ID
  21. outtextxy(50, 30, "Student ID: 123456");
  22.  
  23. // Prompt user to input marks for three subjects
  24. int marksA, marksB, marksC;
  25. cout << "Enter marks for Subject A: ";
  26. cin >> marksA;
  27. cout << "Enter marks for Subject B: ";
  28. cin >> marksB;
  29. cout << "Enter marks for Subject C: ";
  30. cin >> marksC;
  31.  
  32. // Draw bars for each subject
  33. drawBar(150, 400, marksA * 2, 'A');
  34. drawBar(250, 400, marksB * 2, 'B');
  35. drawBar(350, 400, marksC * 2, 'C');
  36.  
  37. getch();
  38. closegraph();
  39. return 0;
  40. }
Success #stdin #stdout 0.04s 25928KB
stdin
Standard input is empty
stdout

#include <iostream>
#include <graphics.h>

using namespace std;

void drawBar(int x, int y, int height, char label) {
    setfillstyle(SOLID_FILL, LIGHTGREEN);
    bar(x, y, x + 50, y - height);
    setcolor(BLACK);
    rectangle(x, y, x + 50, y - height);
    outtextxy(x + 25, y + 10, &label);
}

int main() {
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "");

    // Display student ID
    outtextxy(50, 30, "Student ID: 123456");

    // Prompt user to input marks for three subjects
    int marksA, marksB, marksC;
    cout << "Enter marks for Subject A: ";
    cin >> marksA;
    cout << "Enter marks for Subject B: ";
    cin >> marksB;
    cout << "Enter marks for Subject C: ";
    cin >> marksC;

    // Draw bars for each subject
    drawBar(150, 400, marksA * 2, 'A');
    drawBar(250, 400, marksB * 2, 'B');
    drawBar(350, 400, marksC * 2, 'C');

    getch();
    closegraph();
    return 0;
}