0% found this document useful (0 votes)
77 views

Array of Objects

The document defines a Student class with name and marks data members and getName(), getMarks(), and displayInfo() member functions. The main() function creates an array of 5 Student objects, uses a for loop to get name and marks input for each student using the member functions, and another for loop to display each student's name and marks using displayInfo().

Uploaded by

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

Array of Objects

The document defines a Student class with name and marks data members and getName(), getMarks(), and displayInfo() member functions. The main() function creates an array of 5 Student objects, uses a for loop to get name and marks input for each student using the member functions, and another for loop to display each student's name and marks using displayInfo().

Uploaded by

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

#include <iostream>

class Student
{
string name;
int marks;

public:

void getName()
{
cin>>name;
}
void getMarks()
{
cin >> marks;
}
void displayInfo()
{
cout << "Name : " << name << endl;
cout << "Marks : " << marks << endl;
}
};

int main()
{
Student st[5];
for( int i=0; i<5; i++ )
{
cout << "Student " << i + 1 << endl;
cout << "Enter name" << endl;
st[i].getName();
cout << "Enter marks" << endl;
st[i].getMarks();
}
for( int i=0; i<5; i++ )
{
cout << "Student " << i + 1 << endl;
st[i].displayInfo();
}
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy