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)
#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;
}
Comments
Leave a comment