Question

Can you write a program to convert a string from uppercase to lowercase and lowercase to...

Can you write a program to convert a string from uppercase to lowercase and lowercase to uppercase depending on the user's input? In simple C++ please

So for example if the input is Hello then the output should be hELLO

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <iostream>
#include<string.h>
using namespace std;

void UpperLower(char word[])
{
for(int i=0;i<strlen(word);i++)
{

if(word[i] >= 'A' && word[i] <= 'Z')
{
word[i]=word[i]+32;
}
else
{
word[i]=word[i]-32;
}
}

cout<<word;
}
int main()
{
char word[50];
  
cin>>word;
UpperLower(word);
  
}

output:

Add a comment
Know the answer?
Add Answer to:
Can you write a program to convert a string from uppercase to lowercase and lowercase 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
  • Write a ALP that inputs a string and let's the user choose from uppercase or lowercase...

    Write a ALP that inputs a string and let's the user choose from uppercase or lowercase and vowel and consonant the characters/string to be saved in file. ASSEMBLY LANGUAGE MASM Sample output: Enter a string: RoSE A uppercase vowel B. Lowercase vowel C. Uppercase consonant D.Lowercase consonant Enter choice: c Saving... Program used is emu8086

  • in C++ Write a program that will take a sentence from the user and uses a...

    in C++ Write a program that will take a sentence from the user and uses a ​for loop​ to convert all lowercase characters to uppercase characters. Then output the converted sentence. Example, if the user enters “Hello World”, your program should output “HELLO WORLD”.​ Recall that the ASCII value of ‘A’ is 65 and the ASCII value of ‘a’ is 97. The ASCII value of ‘Z’ is 90 and the ASCII value of ‘z’ is 122. in c++… we can...

  • Using the Arduino IDE, write a program for an Arduino board that will perform the following three...

    Using the Arduino IDE, write a program for an Arduino board that will perform the following three tasks: 1. Input: Prompt the user to enter a character string. Read the character string from your computer through the Arduino's serial interface. 2. Processing: Convert lowercase characters to uppercase and uppercase characters to lowercase, and 3. Output: Return the processed string through the serial output and display it on your computer screen. Example: If the input character string is, “Here I am”,...

  • Write a program that prompts for a sentence and calculates the number of uppercase letters, lowercase...

    Write a program that prompts for a sentence and calculates the number of uppercase letters, lowercase letters, digits, and punctuation. Output the results neatly formatted and labeled in columns. how I can make this program in a more simple way. # get user input user_string = input("Enter a sentence: ") # create and initialize variables upper_case = 0 lower_case = 0 digits = 0 spaces = 0 punctuations = 0 x = len(user_string) #loop conditions and increment for i in...

  • Very difficult and confusing assignment for C++ need help! Write a program that prompts a user...

    Very difficult and confusing assignment for C++ need help! Write a program that prompts a user to enter a line of text (including whitespace). Please use string object NOT C-string, a string library can be included. 1. Convert the input into uppercase and output the string to the screen. 2. Get the first and the last characters then appends the line with "I Love C++" and output the string to the screen. Example: Input: Hello, How are you? Output 1:...

  • Write a program that reads a string from the keyboard and computes the two arrays of...

    Write a program that reads a string from the keyboard and computes the two arrays of integers upperCase, and lowerCase, each of size 26. The first one represents the frequency of upper case letters and the second one represents the frequency of lower case letters in the input string. After computing these arrays, the program prints the frequencies in the following format: The frequency of the letter A= The frequency of the letter B= Assume the input string contains only...

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • Write a program that inputs a string from the user representing a password, and checks its...

    Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...

  • Write a C++ program to get an input string from the user, and output the string...

    Write a C++ program to get an input string from the user, and output the string in uppercase letters. Use a dynamic character array to store the string. ?(this can be from any input file, there is no specific file.)

  • Python Write a program which reads in a string and an signifying the number times the...

    Python Write a program which reads in a string and an signifying the number times the string should be repeated. The program should then output the string N times. integer N, You can assume all input will be valid. Example: Enter a string: hello How many times to repeat? 5 hello hello hello hello hello Example: T Enter a string: goodbye Ty How many times to repeat? 32 goodbye goodbye [... goodbye 30 more times]

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
ADVERTISEMENT