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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started