45.5k views
2 votes
Assume that a program has two String variables named str1 and str2. Write a

pseudocode statement that assigns an all uppercase version of str1 to the str2
variable

In pseudocode or shell-script please.

User Roei
by
7.2k points

1 Answer

5 votes

In pseudocode, you can use the `toUpperCase` method to convert a string to all uppercase letters. Here is a pseudocode statement that assigns an all uppercase version of `str1` to the `str2` variable:

str2 = str1.toUpperCase()

In shell-script, you can use the `tr` command to convert a string to all uppercase letters. Here is a shell-script statement that assigns an all uppercase version of `str1` to the `str2` variable:

str2=$(echo $str1 | tr '[:lower:]' '[:upper:]')

Both of these statements will take the value of `str1`, convert it to all uppercase letters, and assign the result to the `str2` variable.

User Mahi Al Jawad
by
7.4k points