Write a program to get input and output file names from user. Open the file, rea
ID: 665923 • Letter: W
Question
Write a program to get input and output file names from user. Open the file, read each file from the file and write the line you read to an output file along with the length of line.
Example:
InputFile contents:
Hello world
Test
MAC102
C++ programming
Output file contents: (Your program should generate similar outputfile)
Hello world - Length:11
Test - Length:4
MAC102 – Length:6
C++ programming – Length:15
Explanation / Answer
/* * Prompt user for two integers and print their sum, difference, product and quotient * (IntegerArithmetic.cpp) */ #include using namespace std; int main() { int firstInt; // Declare a variable named firstInt of the type int (integer) int secondInt; // Declare a variable named secondInt of the type int int sum, difference, product, quotient; // Declare 4 variables of the type int to keep the results cout > firstInt; // Read input from keyboard (cin) into firstInt cout > secondInt; // Read input into secondInt // Perform arithmetic operations sum = firstInt + secondInt; difference = firstInt - secondInt; product = firstInt * secondInt; quotient = firstInt / secondInt; // Print the results coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.