Mad Libs - prompt the user for every CAPITALIZED word. Then, display the below t
ID: 3764498 • Letter: M
Question
Mad Libs - prompt the user for every CAPITALIZED word. Then, display the below text, replacing the capitalized word with the word the user typed in. You are free to use any variable type you wish unless specified (ie NUMBER (INT)).
Collect input and store it in an array.
The prompt and the user response must be on the same line.
Create at least 1 function to to handle the prompt and pass back the response.
The variables FAMOUS PERSON, OCCUPATION, and PREPOSI- TION must be able to hold multiple words.
Explanation / Answer
fid = fopen('infile.txt','rt') ; X = fread(fid) ; fclose(fid) ; X = char(X.') ; % replace string S1 with string S2 Y = strrep(X, S1, S2) ; fid2 = fopen('outfile.txt','wt') ; fwrite(fid2,Y) ; fclose (fid2) ;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.