1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
DaniilM [7]
3 years ago
7

HW3_P1 - Student list using array

Computers and Technology
1 answer:
Greeley [361]3 years ago
3 0

Answer:

#include<iostream>

#include<cstring>

#include <algorithm>

using namespace std;

class Student{

public:

string name;

int rollNo;

Student(){

}

Student(string n, int r){

name = n;

rollNo = r;

}

};

class ClassRoom{

public:

Student stud[10];

int count;

ClassRoom(){

count = 0;

}

void addStudent(string str,int roll){

Student s(str,roll);

stud[count++] = s;

}

Student * getAllStudents(){

return stud;

}

};

int main()

{

string name;

char temp[20];

int rollNo, N, i;

Student * students;

ClassRoom classRoom;

i=0;

while(getline(cin, name) && cin.getline(temp,20)&&i<10){

rollNo = atoi(temp);

classRoom.addStudent(name, rollNo);

i++;

}

N = i;

students = classRoom.getAllStudents();

for(int i=0 ; i < N; i++){

cout << (students+i)->rollNo << " - " << (students+i)->name;

if(i<N-1)

cout<<endl;

}

return 0;

}

Explanation:

  • In the addStudent method, increment the counter and as the value of variable s to the the stud array.
  • In the getAllStudents method, return all the students.
  • Finally in the main method, display the name and roll no. of students.
You might be interested in
What port in your computer will you use to plug in your camera?
V125BC [204]
I think it would be fire wire
8 0
3 years ago
Read 2 more answers
Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
GalinKa [24]
A Motorcycle would be a good option or get a bike.
7 0
3 years ago
Convert octal number 2470 to decimal number
Vikki [24]
In decimal it is:
0*8^0 + 7*8^1 + 4*8^2 + 2*8^3 = 1336

Basically adding up the place values.
3 0
3 years ago
Read 2 more answers
With a heat exchanger, the temperature of the process fluid can be measured with a temperature-
Ainat [17]
The answer is outlet cooling or process
6 0
3 years ago
What are the most common types of cables in a network?
Maru [420]

the most common are twisted pair, coaxial, Ethernet cross over, and fiber optic.

4 0
3 years ago
Other questions:
  • After calling the customer service line of Delta airlines, Francis received an email asking her to fill out customer satisfactio
    9·1 answer
  • Define and test a function myRange. This function should behave like Python’s standard range function, with the required and opt
    13·2 answers
  • How can i become an expert in computer and technology?
    15·2 answers
  • A specialized security administrator responsible for performing systems development life cycle (SDLC) activities in the developm
    11·1 answer
  • How many times would the following loop iterate?
    15·1 answer
  • Im getting hit offline can someone help or give me some advice
    6·1 answer
  • First Person Who Answers Fast As Possible Will Be Marked As Brainiest ​
    12·1 answer
  • Which option is typically only used when utilizing self joins?
    8·1 answer
  • Taking control of admin functionality and misusing sensitive data that are unauthorized to access are due to.
    8·1 answer
  • Mention and discuss specific professional ethics related to augmented reality, artificial intelligence, and the internet of thin
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!