Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago