0% found this document useful (0 votes)
13 views1 page

New Text Document

The document contains a C++ program that defines a 'Student' structure and functions to print student details based on their branch and pass status. It prompts the user to input student information and displays names of students in the 'computer' branch, successful students, and failed students in the 'control' branch. The program utilizes arrays and loops to manage and display the data effectively.

Uploaded by

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

New Text Document

The document contains a C++ program that defines a 'Student' structure and functions to print student details based on their branch and pass status. It prompts the user to input student information and displays names of students in the 'computer' branch, successful students, and failed students in the 'control' branch. The program utilizes arrays and loops to manage and display the data effectively.

Uploaded by

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

#include <iostream>

#include <string>
using namespace std;
struct Student {
string firstName;
string lastName;
string branch;
bool isPassed;
};
void printNameIfComputer(Student students[], int numStudents) {
for (int i = 0; i < numStudents; i++) {
if (students[i].branch == "computer") {
cout << "First Name: " << students[i].firstName << endl;
cout << "Last Name: " << students[i].lastName << endl;
}
}
}
void printSuccessfulStudents(Student students[], int numStudents) {
cout << "Successful Students:" << endl;
for (int i = 0; i < numStudents; i++) {
if (students[i].isPassed)
cout << students[i].firstName << " " << students[i].lastName << endl;
}
}
void printFailedControlStudents(Student students[], int numStudents) {
cout << "Failed Control Students:" << endl;
for (int i = 0; i < numStudents; i++) {
if (!students[i].isPassed && students[i].branch == "control")
cout << students[i].firstName << " " << students[i].lastName << endl;
}
}
int main() {
int numStudents;
cout << "Enter the number of students: ";
cin >> numStudents;
Student students[numStudents];
for (int i = 0; i < numStudents; i++) {
cout << "Enter the details for student " << i + 1 << ":" << endl;
cout << "First Name: ";
cin >> students[i].firstName;
cout << "Last Name: ";
cin >> students[i].lastName;
cout << "Branch: ";
cin >> students[i].branch;
cout << "Passed (1 = Yes, 0 = No): ";
cin >> students[i].isPassed;
}
cout<<"***********************"<<endl;
printNameIfComputer(students, numStudents);
cout << endl;
printSuccessfulStudents(students, numStudents);
cout << endl;
printFailedControlStudents(students, numStudents);
}

You might also like