You are on page 1of 5

CS602-Computer Graphics Total marks = 20

Assignment No.1 Solution Deadline


Semester: FALL 2023 15th of NOV 2023

Please Carefully Read the Following instructions before attempting the Assignment
Solution

NOTE
Don't copy-paste the same answer.
Make sure you can make some changes to your solution file before submitting copy
paste solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an Assignment GDB Check your assignment Requirement file.

For any query, feel free to Contact at WhatsApp:


+923074960034

Provide by M.JUNAID QAZI

#include <iostream>
#include <graphics.h>
#include <string>
using namespace std;

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, (char*)"C:\\Turboc3\\BGI");

// Input obtained marks for three subjects


int marksA, marksB, marksC;
cout << "Enter obtained marks for Subject A: ";
cin >> marksA;
cout << "Enter obtained marks for Subject B: ";
cin >> marksB;
cout << "Enter obtained marks for Subject C: ";
cin >> marksC;

CONTACT ON WHATSAPP
03074960034
int maxMarks = 100.0; // Maximum marks for each subject (assuming 100)

// Calculate percentages
float percentA = (float)marksA / maxMarks * 360;
float percentB = (float)marksB / maxMarks * 360;
float percentC = (float)marksC / maxMarks * 360;

// Draw the pie chart


int x = getmaxx() / 2;
int y = getmaxy() / 2;
int startAngle = 0;

setfillstyle(SOLID_FILL, RED);
pieslice(x, y, startAngle, startAngle + percentA, 100);

setfillstyle(SOLID_FILL, GREEN);
pieslice(x, y, startAngle + percentA, startAngle + percentA + percentB, 100);

setfillstyle(SOLID_FILL, BLUE);
pieslice(x, y, startAngle + percentA + percentB, startAngle + percentA + percentB + percentC, 100);

// Label the sectors


outtextxy(x + 45, y - 20, (char*)"Subject A");
outtextxy(x - 80, y - 110, (char*)"Subject B");
outtextxy(x - 60, y + 10, (char*)"Subject C");

// Display student ID in the title bar


SetConsoleTitle("M.junaid Qazi");
string studentID = "M.junaid Qazi";
char* studentIDChar = &studentID[0];
settextstyle(3, 0, 2);
outtextxy(250, 10, studentIDChar);

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

CONTACT ON WHATSAPP
03074960034
Different Sample of OUTPUT:

CONTACT ON WHATSAPP
03074960034
CONTACT ON WHATSAPP
03074960034
Every Assignment GDB is change due to unique Student ID so Don’t Copy
That is truly perfect step by step idea solution get help easily.
By The Way if there is any Mistake you found, correct it yourself First Then Submit.

THANKS
M.juniad Qazi
WHATSAPP
+923074960034

CONTACT ON WHATSAPP
03074960034

You might also like