Ask Question
4 February, 06:39

Write a program to convert a string (of up to 20 characters, including the terminating null character) to all uppercase characters. After getting a string that could include spaces (use the fgets () function and don't forget to strip off the ending if it is there), display the original string. Pass the string to a void function (since the 'string' is really as character array) and have the function convert the string to all uppercase by iterating through the string using a for loop and the strlen () function (which is part of the string. h library), and using the toupper () function (which is part of the ctype. h library) to convert each character in the string. Then, back in the main program, display the all uppercase string.

+1
Answers (1)
  1. 4 February, 06:57
    0
    Check the explanation

    Explanation:

    #include

    #include

    #include

    void MyToUpper (char * p)

    {

    int i;

    for (i=0; i
    {

    p[i]=toupper (p[i]);

    }

    }

    int main (void) {

    char str[20];

    printf ("Enter a string:");

    fgets (str, 20, stdin);

    printf ("The string you entered was: %s/n", str);

    MyToUpper (str);

    printf ("The string converted to uppercase is: %s/n", str);

    fflush (stdin);

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program to convert a string (of up to 20 characters, including the terminating null character) to all uppercase characters. After ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers