Write a function bracket_ by_len that takes a word as an input argument and retu
ID: 3556477 • Letter: W
Question
Write a function bracket_ by_len that takes a word as an input argument and returns the word bracketed to indicate its length. Words less than five characters long are bracketed with << >> , words five to ten letters long are bracketed with (* *) , and words over ten characters long are bracketed with /+ +/ . Your function should require the calling function to provide as the first argument, space for the result, and as the third argument, the amount of space available. Consider the expected results of these calls to the function.
For example:
bracket_ by_len(tmp, "insufficiently", 20)
Explanation / Answer
bracket_ by_len(tmp, char *string, int space)
{
int len=strlen(string);
if(len>=5)
printf("the length of string is << %d >> ");
else if(len>5 && len <10)
printf("the length of string is (* %d *) ");
else if(len>10)
printf("the length of string is /+ %d +/");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.