Assume that you are given the details of n students (regno,name,Living City) and list of students who registered for python course. During vacation, your Faculty wants to conduct a physical coding contest for those who lives in Chennai. Help her to find regno of all students in ascending orderSample Input7BCE1001 Mahi DelhiBRS1082 Rathi ChennaiBRS1011 Ranjan HyderabadBRS1900 Kathir ChennaiBRS1901 Kavi APBCE1011 Mahitha UPBCE1111 Harish PunjabSample outputBRS1082BRS1900Use array of structures
Question
Assume that you are given the details of n students (regno,name,Living City) and list of students who registered for python course. During vacation, your Faculty wants to conduct a physical coding contest for those who lives in Chennai. Help her to find regno of all students in ascending orderSample Input7BCE1001 Mahi DelhiBRS1082 Rathi ChennaiBRS1011 Ranjan HyderabadBRS1900 Kathir ChennaiBRS1901 Kavi APBCE1011 Mahitha UPBCE1111 Harish PunjabSample outputBRS1082BRS1900Use array of structures
Solution
To solve this problem, you can follow these steps:
Step 1: Define a structure to hold the student details. In C++, it would look something like this:
struct Student {
string regno;
string name;
string city;
};
Step 2: Create an array of this structure to hold the details of all students.
Student students[n]; // n is the number of students
Step 3: Input the details of all students. This can be done in a loop.
for(int i = 0; i < n; i++) {
cin >> students[i].regno >> students[i].name >> students[i].city;
}
Step 4: Create a new array to hold the registration numbers of students who live in Chennai.
string chennaiStudents[n];
int count = 0;
Step 5: Loop through the students array and if a student lives in Chennai, add their registration number to the chennaiStudents array.
for(int i = 0; i < n; i++) {
if(students[i].city == "Chennai") {
chennaiStudents[count] = students[i].regno;
count++;
}
}
Step 6: Sort the chennaiStudents array in ascending order. You can use the sort function from the algorithm library in C++.
sort(chennaiStudents, chennaiStudents + count);
Step 7: Print the registration numbers of the students who live in Chennai.
for(int i = 0; i < count; i++) {
cout << chennaiStudents[i] << endl;
}
This will give you the registration numbers of all students who live in Chennai, sorted in ascending order.
Similar Questions
Problem StatementIn a computer science class, students are assigned unique identification letters based on their seating arrangement. Each student has a specific letter, and you are tasked with creating a program to sort these letters in ascending order using the bubble sort algorithm. The sorting should be based on their ASCII values. Input the total number of students and their assigned letters, then display the sorted list, allowing the students to easily identify their seating order.Input format :The first line of input consists of an integer N, representing the total number of students.The second line consists of N space-separated characters, each representing the unique identification letter assigned to a student.Output format :The output prints the sorted list of identification letters based on their ASCII values.Refer to the sample output for formatting specifications.Code constraints :1 ≤ N ≤ 15Each identification letter is a valid ASCII character.The input characters are case-sensitive.Sample test cases :Input 1 :5a y h j oOutput 1 :a h j o y Input 2 :7Q G Y O M N BOutput 2 :B G M N O Q Y Input 3 :8a e T V z X h KOutput 3 :K T V X a e h z
You are given 3 lines of input. In the first two lines you have to scan space separated details of the first and the second person respectively in the order: name, admission number, class, percentage, pass result, route number and blood group. Now you will be given an admission number, and you have to return the name, percentage and route of that person in a single line (space-separated). If the admission number is not present, return the error message 'No entry found'. Note that you have to make three classes, a student class(containing name, admission number, and class) and a report class that inherits the student class (and has the percentage and pass result) and a bus class that inherits the student class (and has the route number and blood group). Make appropriate methods where needed and in the driver class, make appropriate calls to these methods for the required output.Sample test case:Input:A 1 9 99 yes 27 B+B 2 10 88 no 28 A+2Output:B 88 28 Explanation: The person whose admission number is 2 has the name B, percentage 88 and route number 28.
Create a database of students using structures, where in each entry of the database will have the following fields:a name, which is a string with at most 128 characterstheir marks in physics, which is an int between 0 and 100their marks in chemistry, which is an int number between 0 and 100their marks in mathematics, which is an int number between 0 and 100You have to output a list of students in the following order.if a student 'A' has lower marks in physics than a student 'B', then A's data is listed before B.If A and B have the same physics marks and A has lower chemistry marks than B, then A is listed before B.If A and B have the same marks in physics and chemistry, and A has lower marks in mathematics than B, then A is listed before B.If all marks are equal and A's name precedes B's name in the dictionary order, then A is listed before B..Input Format :First line contains the number of students n, where 1<=n<=100.In following n lines each line contains(space separated) a name and their respective marks in physics, chemistry, maths, where 0<=marks<=100.Output Format :Sorted database of n lines.
Create a class Student with data members name,regno,CGPADefine a default constructor and read the values of the data members from the user.Define a member function inside the class that will print “eligible for placement “ if CGPA is greater than or equal to 8;else prints “ not eligible”.Create object and call the member function and print the results.Sample InputAkash12347Sample Output1234 Akash is not eligibleInputOutputProcessing InvolvedSolution AlternativesAlgorithm/ Pseudocode
Write a query to display all student details whose sname starts with ‘s’(case sensitive) and is of length between 5 and 20 and squal as ‘undergraduate’(case sensitive). Display the records sorted in ascending order based on sid.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.