Answer to Question #161127 in C++ for zain ul abdeen

Question #161127

 Write a function named upper which takes as input a char array of size 255 and converts it to uppercase. In the main get a string from the user (fgets) and pass it to the upper as an argument. Once the function call is completed, the main should display the modified char array.


1
Expert's answer
2021-02-05T08:06:40-0500


#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>


using namespace std;
void upper(char s[255]){
    for (int i=0; i<strlen(s); i++)
        putchar(toupper(s[i]));
}
int main()
{
    char str[255];
    cout<<"Input a sting to convert to uppercase...\n";
    fgets(str, 255, stdin);
    cout << "The uppercase of """ << str << """ is\n";
    upper(str);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog