Program code in C++
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char a[100], b[100];
int n;
cout<<"Enter a string of size 100(maximum): ";
cin.getline(a,100);
strcpy(b,a);
jump:
strcpy(a,b);
cout<<endl;
cout<<"Enter 1: To print the string"<<endl;
cout<<"Enter 2: To reverse the string"<<endl;
cout<<"Enter 3: To print the length of the
string"<<endl;
cout<<"Enter 4: To convert the string
case"<<endl;
cout<<"Enter 5: To count the lower and upper case
letters"<<endl;
cout<<"Enter 9: To stop the program"<<endl;
cout<<endl<<"Enter your choice: ";
cin>>n;
cout<<endl;
switch(n)
{
case 1: cout<<a<<endl;
goto jump;
case 2:
{
char temp;
int i=0, j;
j=strlen(a)-1;
while(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
i++;
j--;
}
cout<<a<<endl;
goto jump;
}
case 3: cout<<strlen(a)<<endl;
goto jump;
case 4:
for(int i=0;i<strlen(a);i++)
{
if (65<=int(a[i]) && int(a[i])<=90)
{
a[i]=char(int(a[i])+32);
}
else if(int(a[i])>=97 && int(a[i])<=122)
{
a[i]=char(int(a[i])-32);
}
}
cout<<a<<endl;
goto jump;
case 5:
{ int u=0, l=0;
for(int i=0; i<strlen(a); i++)
{
if(int(a[i])>64 && int(a[i])<91)
u++;
else if(int(a[i])>96 && int(a[i])<123)
l++;
}
cout<<"There are "<<l<<" lower case letters and
"<<u<<" upper case letters"<<endl;
}
goto jump;
case 9: return 0;
}
}
Input
Output
Exercise #4: Some Operations on Strings Write a program that uses a C-string to store a...
Use C++ language, keep it simple Exercise #2: Strings' operations Write a C++ program that prompts the user to enter a sentence, the program then does the following: 1. Prints the total characters in the sentence. 2. Prints the word count of the sentence, assuming only one space between each tow words. 3. Prints total vowel (a, e, i, o, u) in the sentence. 4. Prints the vowel frequency as shown in the sample below. 5. Prints the sentence in...
C++ Lab Quiz #3-B Upper Case Letters Write a main() program that reads a string and calls the function int countUpper(string) which counts and returns the number of upper case letters in the string. The main) prints the result Sample inputs/outputs: nter a string: This is a C++ quIz numBer 4 This is a C++ quIz numBer 4" has 5 upper letters
Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...
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 program that uses String method regionMatches to compare two strings input by the user. The program should prompt the user to enter two strings, the starting index in the first string, the starting index in the second string, and the number of characters to be compared. The program should print whether or not the strings are equal, (Ignore the case of the characters during comparison.) 四SAMPLE RUN #1: java StringCompare Highlight: None D Show Highlighted Only Interactive Session...
Must be in JAVA. Write a program that uses a Scanner to read in a String. The program will then output a new String with all the vowels (upper and lower case) removed. See output for example output. Details Input A string composed of non-numeric characters Output The input string with the vowels removed Sample input: Welcome to Dalhousie Sample output: Dlhs nvrsty
PYTHON You are to write a program that will analyze the frequency of letters in a string. The user will enter a string, your program will output the number of times the letters of the alphabet appear in that string. The user is to enter a string that has upper or lower case letters only, no spaces or other characters. You should convert the string entered to all lowercase letters before you conduct your analysis.
Write a Java program which takes a string as a user input. Create 2 functions. The first function expects a string as argument and returns void. It converts all upper case characters to lower case and converts all lower case characters to upper case. It then prints out the converted string to a console. The second function also expects a string as argument and returns void. It will find first charactor that is repeated exactly 2 times in the string....
In this problem, you will write an assembly program (LC-3 assembly language) to process a string starting at memory location x5000, and is terminated by a ‘\0’ character (ASCII value = 0). For a given string beginning atmemory location x5000, convert all the upper-case English letters (A-Z) to lower-case, and all the lower case (a-z) to upper case. For example, if the string is “iLOVEComputerScience252”, the string after the processing should be: “IlovecOMPUTERsCIENCE252”. Store the string after the processing to...
In this problem, you will write an assembly program (LC-3 assembly language) to process a string starting at memory location x5000, and is terminated by a ‘\0’ character (ASCII value = 0). For a given string beginning at memory location x5000, convert all the upper-case English letters (A-Z) to lower-case, and all the lower case (a-z) to upper case. For example, if the string is “iLOVEComputerScience252”, the string after the processing should be: “IlovecOMPUTERsCIENCE252”. Store the string after the processing...