Question: Learning Objectives Read data from input files. Write data to output files. Use file pointers. Instructions Even/Odd A set of numbers is stored in a

Learning Objectives Read data from input files. Write data to output files. Use file pointers.

Instructions Even/Odd

A set of numbers is stored in a file named numbers.txt. Write a program to copy all odd numbers to another file called odd.txt and all even numbers to a file called even.txt.

Sample Input/Output:

Enter the input file name: numbers.txt

Odd Numbers are written to "odd.txt" Even Numbers are written to "even.txt"

Note: The content of file "numbers.txt" is: 12 34 11 23 87 12 1 91 27 15 115 23 72 61 41 61 47

After executing the program:

The content of the file "odd.txt" is: 11 23 87 1 91 27 15 115 23 61 41 61

The content of the file "even.txt" is: 12 34 12 72 */

#include #include using namespace std;

void even(string fileName) { // ToDo // After executing the program: // The content of the file "even.txt" is: 12 34 12 72 // Look inside replit.com file directory to see if the files are created or // not Remember: Test case output (passed) does not validate your code! }

void odd(string fileName) { // ToDo // After executing the program: // The content of the file "odd.txt" is: 11 23 87 1 91 27 15 115 23 61 41 61 // Look inside replit.com file directory to see if the files are created or // not Remember: Test case output (passed) does not validate your code! }

int main() { string fileName; cout << "Enter the input file name: "; cin >> fileName; cout << " Odd Numbers are written to \"odd.txt\""; odd(fileName); cout << " Even Numbers are written to \"even.txt\""; even(fileName); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!