C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 21, Problem 21.9E
Program Plan Intro

Comparing Strings

Program Plan:

  • Include required header files.
  • Define the “main()” function
    • Create a string array str with some string values.
    • Create two string variables str_r and str_ay with values “r” and “ay”.
    • Create integer variable it.
    • Use a loop to iterate it from 0 to 8.
      • Compare each value of string array str with str_r and str_ay to check whether the string contains “r” or “ay” at the end.
      • If the condition satisfies display the string.

The following program uses the compare function to check whether the string contains r and ay at the end and displays the proper string.

/*Include required header files*/
#include <iostream>
#include <string> 
using namespace std;

Blurred answer
Students have asked these similar questions
String - Practice Questions Write a python program using strings to read input from the user and count the character a. Write a python program using strings to read two input and convert the first input to lowercase and second input to uppercase. Write a python program using strings to read input from the use and replace all the character a with z. Write a python program using strings to read input from the user and find the length of the string.
(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string:Jill, Allen (2) Print an error message if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)Ex: Enter input string:Jill AllenError: No comma in string. Enter input string:Jill, Allen (3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts)Ex: Enter input string:Jill, AllenFirst word: JillSecond word: Allen (4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)Ex: Enter input string: Jill, Allen First word: Jill Second word: Allen Enter input string: Golden , Monkey First word: Golden Second word:…
1. Write a program that reads in two integers and determines and prints if the first is a multiple of the second. Hint: use the modulus operator. (%) If you store user's two numbers in num1 & num2 boxes, find the remainder when num1 divide by num2. Also, store the remainder in R box. If R box is zero, num1 is multiple of num2, otherwise, it is not.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License