Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please complete the C code. The code that needs completing is outlined in the co

ID: 3781978 • Letter: P

Question

Please complete the C code. The code that needs completing is outlined in the comments.

#include <stdio.h>

#include <stdlib.h>

/*converts ch to upper case, assuming it is in lower case currently*/

char toUpperCase(char ch){

return ch-'a'+'A';

}

/*converts ch to lower case, assuming it is in upper case currently*/

char toLowerCase(char ch){

return ch-'A'+'a';

}

void sticky(char* word){

/*Convert to sticky caps*/

}

int main(){

/*Read word from the keyboard using scanf*/

/*Call sticky*/

/*Print the new word*/

return 0;

}

Explanation / Answer

Below is the completed code:

#include <stdio.h>

#include <stdlib.h>

/*converts ch to upper case, assuming it is in lower case currently*/

char toUpperCase(char ch){

return ch-'a'+'A';

}

/*converts ch to lower case, assuming it is in upper case currently*/

char toLowerCase(char ch){

return ch-'A'+'a';

}

voidsticky(char*word){

    

    bool upperCase = true;

   

    while(*word != ''){

        if(upperCase){

            *word = toupper(*word);

        }else {

            *word = tolower(*word);

        }

        upperCase = !upperCase;

        word++;

       

    }

}

int main(){

    char word[20];

   

   

    printf("Please enter a word to sticky-fy! ");

    scanf("%19s", word);

   

    sticky(word);

   

    /*Print the new word*/

    printf("%s ", word);

   

    return 0;

}

Thank you.

voidsticky(char*word){

    

    bool upperCase = true;

   

    while(*word != ''){

        if(upperCase){

            *word = toupper(*word);

        }else {

            *word = tolower(*word);

        }

        upperCase = !upperCase;

        word++;

       

    }

}

int main(){

    char word[20];

   

   

    printf("Please enter a word to sticky-fy! ");

    scanf("%19s", word);

   

    sticky(word);

   

    /*Print the new word*/

    printf("%s ", word);

   

    return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote