Answer to Question #218405 in C++ for Fuad Endris

Question #218405
  1. Write a complete C++ code that has a structure like the following structure example:

struct student

{

       char IDNumber[10];

       char Name[20];

       int Age;

       char Department[25];

       float CGPA;

 } ;

Choose your structure name. Include five member variables for your structure. Then do the following questions based on your structure declaration.

a)    Define a function that declares array of student and registers 10 students.

b)    Define a function that displays full information about those 10 students.

c)    Define a function that can be used to update information about the first student.

 

 

 


1
Expert's answer
2021-07-18T01:24:42-0400
#include <iostream>


using namespace std;
struct student


{
    char IDNumber[10];
    char Name[20]; 
    int Age;
    char Department[25];
    float CGPA;


 } ;
 //Define a function that declares array of student and registers 10 students.
void registers(student *s){
    int n=10;
    cout<<"Resister 10 students\n";
    for(int i=0;i<10;i++){
        cout<<"Enter details for student "<<i<<":\n";
        cout<<"\nID number:";
        cin>>s[i].IDNumber;
        cout<<"\nName:";
        cin>>s[i].Name;
        cout<<"\nAge:";
        cin>>s[i].Age;
        cout<<"\nDepartment:";
        cin>>s[i].Department;
        cout<<"\nCGPA:";
        cin>>s[i].CGPA;
    }
}


//Define a function that displays full information about those 10 students.
void display(student *s){
    for(int i=0;i<10;i++){
        cout<<"Details for student "<<i<<":\n";
        cout<<"\nID number:"<<s[i].IDNumber;
        cout<<"\nName:"<<s[i].Name;
        cout<<"\nAge:"<<s[i].Age;
        cout<<"\nDepartment:"<<s[i].Department;
        cout<<"\nCGPA:"<<s[i].CGPA;
    }
}
//Define a function that can be used to update information about the first student.
void update(student *s){
    cout<<"Update details for student 1:\n";
    cout<<"\nID number:";
    cin>>s[0].IDNumber;
    cout<<"\nName:";
    cin>>s[0].Name;
    cout<<"\nAge:";
    cin>>s[0].Age;
    cout<<"\nDepartment:";
    cin>>s[0].Department;
    cout<<"\nCGPA:";
    cin>>s[0].CGPA;
}
int main()
{
    student s1[10];
    registers(s1);
    display(s1);
    update(s1);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Fuad Endris
18.07.21, 22:01

Respect

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS