Program should be in C Write a Program using structure RegI

Program should be in C++

Write a Program using structure (RegI D, Total Marks, CGPA) to get information of the 5 students.

Solution

//C++ code
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>

using namespace std;


struct Student
{
string RegID;
double totalMarks;
double cgpa;
};

void displayStudentData(Student s[], int size)
{
cout << \"\ \ Displaying Information.\" << endl;
for (int i = 0; i < size; ++i)
{
cout << \"Student #\" << (i+1) << endl;
cout << \"Reg ID: \" << s[i].RegID << endl;
cout << \"Total marks: \" << s[i].totalMarks << endl;
cout << \"CGPA: \" << s[i].cgpa << endl << endl;
}
  
}

int main()
{
Student s[5];

for (int i = 0; i < 5; ++i)
{
cout << \"Enter registration ID of Student \" << (i+1) << \": \";
cin >> s[i].RegID;
cout << \"Enter total marks of Student \" << (i+1) << \": \";
cin >> s[i].totalMarks;
cout << \"Enter cgpa of Student \" << (i+1) << \": \";
cin >> s[i].cgpa;
}
  

// Function call with structure variable as an argument
displayStudentData(s, 5);

return 0;
}

/*
output:
Enter registration ID of Student 1: 34416
Enter total marks of Student 1: 98
Enter cgpa of Student 1: 9.8
Enter registration ID of Student 2: 78965
Enter total marks of Student 2: 87
Enter cgpa of Student 2: 8.7
Enter registration ID of Student 3: 34221
Enter total marks of Student 3: 67
Enter cgpa of Student 3: 6.7
Enter registration ID of Student 4: 45667
Enter total marks of Student 4: 77
Enter cgpa of Student 4: 7.7
Enter registration ID of Student 5: 45445
Enter total marks of Student 5: 66
Enter cgpa of Student 5: 6.6


Displaying Information.
Student #1
Reg ID: 34416
Total marks: 98
CGPA: 9.8

Student #2
Reg ID: 78965
Total marks: 87
CGPA: 8.7

Student #3
Reg ID: 34221
Total marks: 67
CGPA: 6.7

Student #4
Reg ID: 45667
Total marks: 77
CGPA: 7.7

Student #5
Reg ID: 45445
Total marks: 66
CGPA: 6.6


*/

Program should be in C++ Write a Program using structure (RegI D, Total Marks, CGPA) to get information of the 5 students.Solution//C++ code #include <fstrea
Program should be in C++ Write a Program using structure (RegI D, Total Marks, CGPA) to get information of the 5 students.Solution//C++ code #include <fstrea

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site