Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
578 views
in Arrays and Structures by (49.1k points)
closed by

Write a C++ program to declare and accept an array of professors. Display the details of the department= “COMP.SCI” and the name of the professors start with ‘A’. The structure “college” should contain the following members.

prof id as integer

name and Department as character array

1 Answer

+1 vote
by (54.8k points)
selected by
 
Best answer

#include<iostream>

using namespace std;

struct professor

{

int id;

char name[20];

char dept[20];

}

void accept(Professor 7 p);// Function declaration

{

cout<<"\n "Enter id of Professor:";

cin>>p.id;

cout<<"\n "Enter name of the Professor:";

cin>>p.name;

cout<<"\n "Enter name of the department:";

cin>>p.dept;

}

Void display(Professor p)

{

cout<<"\n professor id";

cin>>p.id;

cout<<"\n professor Name:";

cout<<p.name;

cout<<"\n Department:";

cout<<p.dept<<end1;

}

int main()

{

Professor p[5];

int total = 0;

for(int i = 0;i<5;i++)

{

cout<<"\n professor"<<i+1<<"\n; accept P[i];

}

cout<<"\n Name of the  professor starting with A \n";

for(int i = 0;i<5;i++)

{

if(P[i].name[0] = ='A'&& P[i].dept = =''CS")

{

cout<<"\n professor"<<i+1<<"\n";

display(P[i]);

}

cin.get(); din.get();

return 0;

}

Output

Professor 1

Enter id of professor: 100

Enter name of the professor: John

Enter name of the department: CS

Professor 2

Enter id of professor: 101

Enter name of the professor: Janardhan 

Enter name of the department: ECE

Professor 3

Enter id of professor: 102

Enter name of the professor: Albert

Enter name of the department: CS

Professor 4

Enter id of professor: 103

Enter name of the professor: Asha

Enter name of the department: CS

Professor 5

Enter id of professor: 104

Enter name of the professor: Han

Enter name of the department: EEE

Name of the professor starting with A 

Professor 1

Enter id of professor: 102

Enter name of the professor: Albert

Enter name of the department: CS

Professor 2.

Enter id of professor: 103

Enter name of the professor: Asha

Enter name of the department: CS

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...