Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3 Exercise: Character Operations on Strings Exercise 3 : Complete the implementations of the functions below, which will have similar behavior to parts of Assignment
3 Exercise: Character Operations on Strings
Exercise 3: Complete the implementations of the functions below, which will have similar behavior to parts of Assignment 2, but with strings instead of user input. Do not modify main().
#include#include #include int count_characters(char str[]){ /* Your Code Here */ } int count_words(char str[]){ /* Your Code Here */ } void capitalize(char str[]){ /* Your Code Here */ } void invert_capitalization(char str[]){ /* Your Code Here */ } int main(){ char S1[] = "Raspberry"; char S2[] = " "; //Contains 0 words, 6 characters char S3[] = "CSc 111 SPRing 2018"; char S4[] = " raspberry pear pineapple banana"; char S5[] = " <-- spaces at the beginning, spaces at the end --> "; //Make a new array to use as temporary storage. char W[1000]; printf("S1: \"%s\" ", S1 ); printf("Characters: %d ", count_characters(S1) ); printf("Words: %d ", count_words(S1) ); strcpy(W, S1); capitalize(W); printf("Capitalized: \"%s\" ", W ); strcpy(W, S1); invert_capitalization(W); printf("Inverted Capitalization: \"%s\" ", W ); printf(" "); printf("S2: \"%s\" ", S2 ); printf("Characters: %d ", count_characters(S2) ); printf("Words: %d ", count_words(S2) ); strcpy(W, S2); capitalize(W); printf("Capitalized: \"%s\" ", W ); strcpy(W, S2); invert_capitalization(W); printf("Inverted Capitalization: \"%s\" ", W ); printf(" "); printf("S3: \"%s\" ", S3); printf("Characters: %d ", count_characters(S3) ); printf("Words: %d ", count_words(S3) ); strcpy(W, S3); capitalize(W); printf("Capitalized: \"%s\" ", W ); strcpy(W, S3); invert_capitalization(W); printf("Inverted Capitalization: \"%s\" ", W ); printf(" "); printf("S4: \"%s\" ", S4 ); printf("Characters: %d ", count_characters(S4) ); printf("Words: %d ", count_words(S4) ); strcpy(W, S4); capitalize(W); printf("Capitalized: \"%s\" ", W ); strcpy(W, S4); invert_capitalization(W); printf("Inverted Capitalization: \"%s\" ", W ); printf(" "); printf("S5: \"%s\" ", S5 ); printf("Characters: %d ", count_characters(S5) ); printf("Words: %d ", count_words(S5) ); strcpy(W, S5); capitalize(W); printf("Capitalized: \"%s\" ", W ); strcpy(W, S5); invert_capitalization(W); printf("Inverted Capitalization: \"%s\" ", W ); printf(" "); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started