Question

-Brief description of the program: - input(s) and output(s) - brief description or relationship between inputs and outputs Su

-Write in C++ language.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// inputText.txt

birds and bees
hope is what defines man
the quick brown fox jumps over a lazy dog

_________________________
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;

void revStringInWord(string &str);
int main() {
   string line;
//defines an input stream for the data file  
ifstream dataIn;
  
//Defines an output stream for the data file
ofstream dataOut;
  
  
//Opening the input file
dataIn.open("inputText.txt");
//checking whether the file name is valid or not
if(dataIn.fail())
{
   cout<<"** File Not Found **";
return 1;
}
else
{
   //creating and Opening the output file
dataOut.open("output.txt");
   while(!dataIn.eof())
   {
       getline(dataIn,line);
       revStringInWord(line);
       dataOut<<line<<endl;
   }
   //Closing the intput file
dataIn.close();

  
//Closing the output file.
dataOut.close();
}

  


  
  
  
  
return 0;
}
void revStringInWord(string &str)
{
   char temp;
int start,end,i,j=0,len;
//To find the length of string
len=str.length();
  
//To reverse whole string
for(i=0;i<(len/2);i++)
{
temp=str[i];
str[i]=str[len-1-i];
str[len-1-i]=temp;
}

  
//This loop will reverse each word seperately
for(i=0;i<=len;i++)
{
if(str[i]==' ' || str[i]=='\0')
{
for(start=j,end=i-1 ; start<(i+j)/2 ; start++,end--)
{
temp=str[start];
str[start]=str[end];
str[end]=temp;
}

j=i+1;
}
}

}

______________________

Output file(output.txt)

output Notepad File Edit Format View Help bees and birds man defines what is hope dog lazy a over jumps fox brown quick the


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
-Brief description of the program: - input(s) and output(s) - brief description or relationship b...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python 3:Write a program that inputs a text file. The program should print the unique words...

    Python 3:Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order.   Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order An example file along with the correct output is shown below: example.txt the quick brown fox jumps over the lazy dog Enter the input file name: example.txt brown dog fox jumps lazy over quick the

  • I/O program for C Write a program in direct1.c which reads from standard input a line...

    I/O program for C Write a program in direct1.c which reads from standard input a line and then outputs that line immediately to standard output. it should read the first line only ! Then, write another program called direct2.c which reads from standard input every line until end of input and outputs them to standard output. Everything that goes in should come out exactly as it was. Compile both programs and run them on the input files given below The...

  • Please solve. How do I create my own text file? Where do I save it so...

    Please solve. How do I create my own text file? Where do I save it so that it is recognized by python? Do I have to import it into my code? the prompt: Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. An example file along with the correct output is shown below: example.txt the quick brown fox jumps over the lazy dog Enter the input file name:...

  • Write a program using regular expression to find the starting and ending locations of ‘fox’ in...

    Write a program using regular expression to find the starting and ending locations of ‘fox’ in the text 'The quick brown fox jumps over the lazy dog.' Then print out its locations as follows: Found fox from (the starting location) to (the ending location).

  • Simple Python Program Working with strings Write a Python program to read in a number of...

    Simple Python Program Working with strings Write a Python program to read in a number of strings from the user. Stop when the user enters “Done”. Then check if each of the strings contains all the letters of the alphabet. Print the results in the form of a dictionary, where they keys are the strings and the values are the Truth Value for the string, which you just calculated. Sample Run: Enter the strings: taco cat The quick brown fox...

  • Using the website Repl.it Write a Java program that can perform the Caesar cipher for English...

    Using the website Repl.it Write a Java program that can perform the Caesar cipher for English messages that include both upper and lowercase alphabetic characters. The Caesar cipher replaces each plaintext letter with a different one, by a fixed number of places down the alphabet. The program should be able to shift a specific number of places based on the user's input number. For example Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. Ciphertext: QEBNRFZH YOLTK CLU GRJMP...

  • IN C++ Write a program in c++ that will read from a file the following sentence:...

    IN C++ Write a program in c++ that will read from a file the following sentence: The quick brown fox jumps over the lazy dog Each word must be read into one location in an array beginning with the first element. You must declare an array as follows: char *words [9] ; // this is an array of c- strings. HINT words[0] will contain "the" words[1] will contain "quick" write a function int length (const char *a) to determine the...

  • Write a python program that does the following: takes as input from the user an English...

    Write a python program that does the following: takes as input from the user an English sentence calls the function vc_counter() that: takes a string argument counts the number of vowels and consonants in the string returns a dictionary of the counts, using the keys total_vowels and total_consonants Uses the return from vc_counter() to print the total vowels and consonants with appropriate descriptions. Example: Enter an English sentence: The quick brown fox's jump landed past the lazy dog! Total #...

  • i am trying to write a subroutine in assembly that removes all occurrences of a given...

    i am trying to write a subroutine in assembly that removes all occurrences of a given character in a string. The subroutine takes two parameters: the string pointer, and the character to be removed. Write a C code that calls this subroutine. The string is defined in the C source code file as global. Assume the assembly and C code are in separate files. Use Keil/uVision to test your program where the C code should ask the assembly subroutine to...

  • 1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write...

    1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write a Python program that prompts the user for a sentence, then replaces all the vowels in the sentence with an asterisk: '*' Your program should use/call your isVowel function from Assignment_Ch06-01. You can put the isVowel() function in a separate .py file, without the rest of the Ch06-01 code, and then import it. 6-01 CODE: def isVowel(x):     if x in "aeiouyAEIOUY":         return True     else:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT