Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Task 4

Enter the marks of 5 students in Computer Programming, ICT and Object-Oriented


Programming (each out of 100) using a structure named Marks having elements roll no.,
name, cp_marks, ict_marks and oop_marks and then display the percentage of each student.

Source code
#include<iostream>
#include<string>
using namespace std;

struct Marks
{
int roll;
string name;
float cp_marks, ict_marks, oop_marks;

void get_data()
{
cout << "Enter roll no::" << endl;
cin >> roll;
cout << "Enter name::" << endl;
cin >> name;
cout << "Enter ICT Marks::" << endl;
cin >> ict_marks;
cout << "Enter OOP Marks::" << endl;
cin >> oop_marks;
cout << "Enter CP Marks::" << endl;
cin >> cp_marks;

}
void Display_percent()
{
float sum;
float percent;
sum = ict_marks + oop_marks + cp_marks;
percent = (sum /300)*100;
cout << percent<<endl;

}
};

int main()
{
Marks s[5];
for (int i = 0; i < 5; i++)
{
cout << "ENter Student "<<i+1<<" Data" << endl;
s[i].get_data();
}

system("cls");
for (int j = 0; j < 5; j++)
{
cout << "Student"<< j +1<<" Percent" << endl;
s[j].Display_percent();
}
system("pause");
return 0;
}

You might also like