Question

Question 4 5 Write a function to upper that converts a string from lower case to change it to HELLO: Remember that you can test if a char is between a and z. inclusive, and that capital chars int main0i upper case. For the following function, to upper should accept hello as an are 32 less than lower case chars char sil hello printf(s-%s\n, s); to uppers): printf(s-%sin, s); return O: The program output should be: s hello s HELLO HTML Editor Paragraph

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

void to_upper(char s[]) {
    int i = 0;
    while(s[i]) {
        if(s[i] >= 'a' && s[i] <= 'z') {
            s[i] -= 32;
        }
        i++;
    }
}

int main()
{
    char s[] = "hello";
    printf("s = %s\n", s);
    to_upper(s);
    printf("s = %s\n", s);
    return 0;
}

s hello s HELLO

\color{blue}Hey,\;Please\;let\;me\;know\;if\;you\;need\;me\;to\;make\;any\;changes. \\ I\;would\;really\;appreciate\;an\;upvote.\;Thank\;you!

Add a comment
Know the answer?
Add Answer to:
Question 4 5 Write a function to upper that converts a string from lower case to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT