Please do it with C++. Thanks:)
Write a program that reads a string and a character from the keyboard. The program should output how many times the character appears in the string. Make the program run in a loop until the string finish is input.
Sample run:
Input a string: alicia Input a letter: a The letter appears 2 times Input a string: felix Input a letter: x The letter appears 1 time Input a string: finish Good Bye.
#include <iostream>
using namespace std;
int main() {
string str;
char ch;
int count = 0;
do{
count = 0;
cout<<"Input a string: ";
cin>>str;
if(str=="finish"){
cout<<"Good Bye.";
break;
}
cout<<"Input a letter: ";
cin>>ch;
for(int i=0 ;i< str.size();++i){
if(str.at(i)==ch)
++count;
}
cout<<"The letter appears "<<count<< "
times"<<endl;
}while(1);
}
===================================================
See Output
Thanks, PLEASE RATE. let me know if there is any
concern.
Please do it with C++. Thanks:) Write a program that reads a string and a character...
Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times the character appears in the phrase. Ex: If the input is: n Monday the output is: 1 Ex: If the input is: t this is a sentence with many t's the output is: 4 PLEASE WRITE USING PYTHON
Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times the character appears in the phrase. Ex: If the input is: n Monday the output is: 1 Ex: If the input is: z Today is Monday the output is: 0 Ex: If the input is: n It's a sunny day the output is: 2 Case matters. Ex: If the input is: n Nobody the output is: 0...
Write a program in python that asks the user to input a sentence. The program will ask the user what two letters are to be counted. You must use a “for” loop to go through the sentence & count how many times the chosen letter appears in the sentence. You are not allowed to use python built-in function "count()" or you'll get a Zero! Output will show the sentence, the letter, and the number of times the letter appears in...
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. Ex: If the input is: n Monday, the output is: 1 Ex: If the input is: z Today is Monday, the output is: 0 Ex: If the input is: n It's a sunny day, the output is: 2 Case matters. Ex: If the input is: n Nobody, the output is: 0 n is different than...
4A. Write a CUDA host program that reads a character type matrix A and integer type matrix B of size mxn. It produces an output string STR such that, every character of A is repeated n times (where n is the integer value in matrix B which is having the same index as that of the character taken in A). Solve this using 1D Block. Example: 1 2 4 3 e X a M Output String STR: pCCaaaaPPPeeXXXXaaaMM 4B. Write...
Create an algorithm for a program that reads a string with a maximum length of 30 from the keyboard. The algorithm should then copy the characters from that string into a second character array in order but only if the character is a vowel (a, e, i, o, u). Once copied, the algorithm should output these values in order. The algorithm should then count and display the number of times each vowel appears in the array. Finally, the algorithm should...
Write in C. Simple Program (beginner) Assignment: Write a program Character Pointers and Functions. (like program #5-5). Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count. <END>
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]
Write a Java program that reads in a word from the user and outputs each character of the word on a separate line. For example, if the user enters the input "Joe", your program should output: J o e You need to use a for-loop.
Instructions In c++ write a program that reads in a string of zeros and ones without spaces and for each 8 digits (one byte) outputs the corresponding value in decimal format. The output numbers are separated by spaces. Stop when a character different than 0 or 1 is encountered. The final output may be generated from less than 8 digits but no output should be generated for the final character. Should work for example: input: 00000011000000010010X output: 3 1 2