Answer to Question #335269 in C++ for Hanna

Question #335269

Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use a character


array to store the string.)



(Must be implemented using dynamic array)

1
Expert's answer
2022-04-29T08:21:17-0400
#include <iostream>
#include <string>
using namespace std;

int main()
{
    char str[20];
    char upper_str[20];
    cout << "Enter a string: ";
    cin >> str;
    
    cout << "The string you entered is: " << str << endl;
    for(int i = 0; i < 20; i++)
    {
       char ch = str[i];
	   if(ch != ' ')
	   {
	   	 upper_str[i] = toupper(ch);
		}	
	}
    cout << "The uppercase string is: " <<upper_str<<endl;
    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
APPROVED BY CLIENTS