Write a C++ program that asks the user to input the following details of a student student_ID, name, email_address, department, phone_number Then, save these entered details in a file named “student.txt” and ask the user if he/she wants to enter any new record. If the user enters ‘Y’, then repeat the process again and save/append the newly entered record’s details in the file. If the user enters ‘N’, then the program should exit. See the sample output below:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct Data
    string name;
    string id ;
    string email;
    string departement;
    string phoneNumber;
int main(){
    int size = 1;
    char choice;
    ofstream hout("Student.txt");
    Data* d = new Data[size];
        cout << "Enter Id. ";
        getline (cin,d->id);
        cout << "Enter Name. " ;
        getline (cin, d->name);
        cout << "Enter email address " ;
        getline (cin, d->email);
        cout << "Enter departement " ;
        getline (cin, d->departement);
        cout << "Enter Phone Number. " ;
        getline (cin, d->phoneNumber);
        hout << "Id. "<<d->id;
        hout << "Name. " << d->name;
        hout << "email address " << d->email;
        hout << "departement " << d->departement;
        hout << "Phone Number. " << d->phoneNumber;
        cout <<"Do you want to enter new record (y/n). ";
        cin >> choice;
    } while (choice != 'n');


cpp programming exercise with solution
cpp programming exercise with solution