Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how would I write a flow chart for #include <iostream> #include <fstream> using

ID: 3643963 • Letter: H

Question

how would I write a flow chart for
#include <iostream>
#include <fstream>
using namespace std;

// constant variables
const int ARRAY_SIZE = 10;
const int NAME_SIZE = 20;

// function prototypes
void arrayToFile(char[], int[], int);
void fileToArray(char[], int[], int);



int main()
{

int arrayContents[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int arrayContents2[ARRAY_SIZE];
int* intPointer2;
int* intPointer;
intPointer = arrayContents;
intPointer2 = arrayContents2;
char fileName[NAME_SIZE];

cout << "Chapter 12 Program 8" << endl << endl;
cout << "Enter name of file." << endl << endl;
cin.getline(fileName, NAME_SIZE);
arrayToFile(fileName, arrayContents, ARRAY_SIZE);
fileToArray(fileName, arrayContents2, ARRAY_SIZE);

//dislplay contents of arrayContents2
for (int count = 0; count < ARRAY_SIZE; count++)
{
cout << intPointer[count] << " ";
}


return 0;
}

void arrayToFile( char file[], int pointer[], int arr_size)
{
fstream dataFile;
dataFile.open(file, ios::in | ios::binary);
for (int count = 0; count < arr_size; count++)
{
dataFile.write(reinterpret_cast<char *>(pointer), sizeof(pointer));
}

dataFile.close();

}

void fileToArray( char file[], int pointer[], int arr_size)
{
fstream dataFile;
dataFile.open(file, ios::out | ios::binary);
for (int count = 0; count < arr_size; count++)
{
dataFile.read(reinterpret_cast<char *>(pointer), sizeof(pointer));
}

dataFile.close();
}

Explanation / Answer

Draw the flowchart using any software Here are the steps Start Initialise array Get filename from user Open file Write content of the array (arrayContents) into the file Close file Open file read till the end of the file and store the content into the array (arrayContents2) Close file Display the array arrayContents2 End