1. Write a program to remove unnecessary blanks from a text file. Your program should read the text file and copy it to

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. Write a program to remove unnecessary blanks from a text file. Your program should read the text file and copy it to

Post by answerhappygod »

1.
Write a program to remove unnecessary blanks from a text file.Your programshould read the text file and copy it to another text file, butwhenever more than oneblank occurs consecutively, only one blank should be copied to thesecond file. The second file should be identical to the first file, except that allconsecutive blanks have been replaced by a single blank.
If the input file e.g. looked like this:
What a beautiful day! I wish I was at the beach…The output file should look like this:What a beautiful day! I wish I was at the beach…
NB: First plan your program on paper (using your computationalthinking to do so).You have to submit your plan for your program as well as the actualprogramcode, input and output files. Planning your program can take theform of a flowchart,pseudocode, or notes to guide you in the development of theprogram.
2.
A palindrome is a word spelled the same way backwards andforwards. For example,Anna, radar, madam and racecar are all palindromes. Certain wordscan be turned into palindromes when the first letter is removed and added at theback, e.g. ‘potato’ will read the same backwards if we remove the ‘p’ and add it at theback, i.e. ‘otatop’read backwards will still say ‘potato’. Similarly, ‘banana’ when you remove the ‘b’ and add it at the backso that it becomes‘ananab’ will still say ‘banana’ if you read it backwards. Write a program that reads a word into a C-string (a characterarray). The programshould then determine whether the word would be a palindrome if weremove the firstcharacter and add it at the back of the word. Use only C-stringfunctions and C-strings. Assume that we will not work with words longer than 20characters.Hint: You may consider using the C-string function strrev() but itis not compulsory.Remember to plan your program!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply