Can you help me with this question plz?? Generate ten objects of your class by u
ID: 3615597 • Letter: C
Question
Can you help me with this question plz?? Generate ten objects of your class by using arrays,then set all its parameters using a for loop.print all objects along its attributes in a tabular format(organized using spaces and dashs) as well as
finding the max and min of the attributes for the 10 objects. special thanks Can you help me with this question plz?? Generate ten objects of your class by using arrays,then set all its parameters using a for loop.
print all objects along its attributes in a tabular format(organized using spaces and dashs) as well as
finding the max and min of the attributes for the 10 objects. special thanks
Explanation / Answer
#includ<iostream>
using namespace std;
class Student{
private int rollno;
private int age;
public int getage()
{
return age;
}
public int getroll()
{
return rollno;
}
public void setroll(int rl)
{
rollno=rl;
}
public void setage(int g)
{
age=g;
}
}
int main()
{
Student std[10];
int roll,age;
for(int v=0;v<10;v++)
{
cout<<”Enter Roll No;”;
cin>>roll;
std[v].setroll(roll);
cout<<”Enter Age;”;
cin>>age;
std[v].setage(age);
}
cout<<”Roll No.”<<” Age”;
for(int v=0;v<10;v++)
{
cout<<std[v].getroll();
cout<<” ”;
cout<<std[v].getage()<<endl;
}
system(“pause”);
return 0;
}
Hope it is helpful to you...