Create Sequential Text File2

//This program will create a two squential text file

#include <fstream.h>
#include <iostream.h>

ofstream fp; //Declare a file pointer for writing
main()
{
        float num;
        char name[10];
        fp.open ("trans.dat", ios::out); //Create the sequential (text) file

        for (int k = 0; k <= 1; k++)
        {
                cout <<"Please enter a last name : ";
                cin >> name;
                fp << name << '\n';
                for (int i = 0; i <= 2; i++)
                {
                    cout << "Enter Transaction : " << i + 1 << " : ";
                    cin >> num;
                    fp << num << '\n';
                }
                cout << '\n';
        }

fp.close();// closing the sequential (text) file

return 0;
}
/*
Please enter a last name : Jones
Enter Transaction : 1 : 23.56
Enter Transaction : 2 : 12.54
Enter Transaction : 3 : 234.23

Please enter a last name : Smith
Enter Transaction : 1 : 10.34
Enter Transaction : 2 : 25.34
Enter Transaction : 3 : 26.33

trans.dat (Sequential Text File)
Jones
23.56
12.54
234.23
Smith
10.34
25.34
26.33

*/