0% found this document useful (0 votes)
29 views4 pages

C++ Experiment 03

Uploaded by

Ameya Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

C++ Experiment 03

Uploaded by

Ameya Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Expt No.

3 Date

c++ code to define student class with USN no, name and marks in 3
tests of a subject.declare an array of 10 students in object using 10
students using an appropriate functions, find the average of two better
marks for each student .print the USN,name and the average marks of
all students

#include<iostream>

using namespace std;

class STUDENT

public:

string USN,name;

int marks[3];

void getdetails()

cout<<"enter USN : ";

cin>>USN;

cout<<"enter name : ";

cin>>name;

cout<<"enter 3 test marks : ";

for(int i=0;i<3;i++)

cin>>marks[i];

void printdetails()

cout<<"Name : "<<name<<endl;
cout<<"USN : "<<USN<<endl;

double calculate_avg()

int sum=0;

int min=marks[0];

for(int i=0;i<3;i++)

sum +=marks[i];

if(marks[i]<min)

min=marks[i];

return(sum-min)/2.0;

};

int main()

STUDENT students[10];

for(int i=0;i<10;i++)

cout<<"enter the details of students : "<<i+1<<endl;

students[i].getdetails();

cout<<"average marks : "<<students[i].calculate_avg()<<endl;

cout<<endl;

}
return 0;

OUTPUT :-
Entered 10 Student details with USN,NAME & 3 test marks & got the output
as avg marks

You might also like