According to research, we don’t actually read every character in a word, but rather recognize the words as a whole. As long as the first and last letters of each word are in place, the middle letters can be arranged in any order, and the words will still be readable. For example:
Aoccdrnig to a rscheearch at an Elingsh uinervtisy, it deosn’t mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer is at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae we do not raed ervey lteter by it slef, but the wrod as a wlohe.
Write a program that will create scrambled words by circularly rotating the middle characters of each word by 1 character. Place the scrambled words, 1 per line in an output file.
hamster — hmstear
The Input File format is such that the first line contains a number indicating the number of words in the file, followed by one line for every word to be scrambled (no spaces in any of the words).
Sample input file: 4 dog pepper marker teapot
Sample output file: dog pppeer mrkear tapoet
No word is more than 80 characters long in the input file.
The input file name is ***** ***** Put all output in a file called scramble.txt
If a file fails to open, ensure you display an appropriate error message.
If the first line of the input file does not contain a number, display an error message and stop.
Do not attempt to open / create the output file if any errors have occurred in opening the input file and reading the number containing the number of lines.
The following instructions must be adhered to. Variance from these instructions will result in a penalty of 50% of the assignment:
1. 1. The use of any of the following C statements or functions is not permitted under any circumstances.
• o break; (except when used in a switch() statement)
• o continue;
• o exit();
• o abort();
• o goto
• 2. All user input must be validated:
• o Check for non-numeric input when reading numeric input
• o Check that values entered are within the expected range for their purpose, or in range based on the requirements statement
• 3. Global variable declarations are not permitted- all variables must be declared within the function they are used (e.g. main())
• 4. Carefully read the instructions for each program, as mandatory design criteria may be provided.
• Common issues with assignments include the following:
• No modularity
• Poor or missing comments (file and module header comments)
• Not testing for non-numeric input
Produces Correct Results and is Written to Spec
Program Design (modularity)