Ask Question
7 November, 15:34

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.

+4
Answers (1)
  1. 7 November, 17:56
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers