Lawrence Technological University Department of Mathematics and Computer Science MCS 1142 ntroduction to C ! "all 2##$ This homework assignment builds builds on the previous assignments. In the last assignment you called calcAndPrint () with 3 input parameters parameters 2 of which were arrays. One array contained the format strings used in the printf() statements in calcAndPrint (). !or this assignment I want you add a new function" modifyFormats modifyFormats()" that will be called on the array of format strings like this#
modifyFormats(f modifyFormats(formats[ ormats[], ], 5); where formats is the array of format strings and is the integer number of entries in the array. modifyFormats() from the main() function right after you copy the format $ou should call modifyFormats strings into the array but before you call calcAndPrint ().
modifyFormats() I want you to modify the format strings ( formats%&) so that the words In modifyFormats radius" area" and circum are in capital letters. To do this use the string manipulation function strstr () to pick out the beginning of the substring in 'uestion (either radius" area" or circum). et remember you can modify individual characters in a string by using a pointer to the character like this *
*subStr = ‘!; +lso remember you you can advance a substring pointer by simply simply incrementing it like this#
subStr""; Therefore you can combine these commands commands to replace a lower case word with with upper case. !or eample" to replace the word radius you would do the following#
*subStr *subStr *subStr *subStr *subStr *subStr
= = = = = =
##; #A#; #$#; #%#; # #S#;
subStr""; subStr""; subStr""; subStr""; subStr"";
The five elements in formats should be each of the five different format strings used in the printf() function calls in calcAndPrint (). These strings should should be defined in in the main function like this#
Once these character strings are created and stored in formats " calcAndPrint () can be called with the three input parameters like this#
calcAndPrint(, radii, formats); Inside calcAndPrint ()" the printf() calls should now use the entries in formats for the format strings rather than string literals. ,elow is an eample of how the printf() call to print a circle radius would look#
'' alculat and print circumf and ara for t circl printf(formats[-], loop8countr"4, radii[loop8countr]); $ou can use the input file you used for assignment -. It should have the structure below# 2 3
./ /./ -.3
The output should have the following format (0lease note the capital letters1)# ircle +4I56# ircle I58# ircle +9+#
777.77 777.77 ot alculated
ircle 2 +4I56# ircle 2 I58# ircle 2 +9+#
777.77 ot alculated 777.77
ircle 3 +4I56# ircle 3 I58# ircle 3 +9+#
777.77 ot alculated ot alculated
4on:t forget the following program head for all programs submitted for grading.
// Program Author: // Student ID: // Email Address: // "ame o# Program: // Program Due Date: // '()e$ti*e: assignment // Program Des$ri,tion: // onor ode: // elses //
9n;oy1
Your name xx000012345 xxltu!edu "ame o# Program!$ %%&DD&YY +he Instru$tors des$ri,tion o# the ,rogramming +he Students des$ri,tion o# ho- the ,rogram -or.s I ha*e neither gi*en nor re$ei*ed unauthoried aid in $om,leting this -or. nor ha*e I ,resented someone -or. as m o-n
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.