Programming and Problem Solving With C++
Programming and Problem Solving With C++
6th Edition
ISBN: 9781449694265
Author: Nell Dale
Publisher: Jones & Bartlett Learning
bartleby

Videos

Question
Book Icon
Chapter 3, Problem 8PP
Program Plan Intro

Program Plan:

To output the length of a name using proper formatting and appropriate comments.

Following functions are used in the program:

Getline(): used to read a string from console.

find(): used to find the index of the first occurrence of the sub-string being called in the specified string.

substr(pos,n): It is a predefined function that returns a copied string for n characters starting with the index pos.

length(): returns the length of a string.

cout: used to display output to the console.

Summary Introduction:

Program will use the main () method to ask the user to enter the string name. find() method is used to get the index(i) of the first occurrence of space delimiter then extract the first name(substring) from index 0 to index i of string name using substr() method. Similarly, middle name and last name are extracted and finally print the first name, middle name and last name of string name.

Program Description:

The purpose of the program is to break and print the string name entered by the user in three parts as first name, middle name, and last name and find their lengths.

Blurred answer
Students have asked these similar questions
A palindrome is a string that reads the same both forward and backward. For example, the string "madam" or “level” are a palindrome. Write a program in C++ that uses a function to check whether a string is a palindrome. Your program must contain a value-returning function that returns true if the string is a palindrome and false otherwise. note: use DSA concepts
In C++ For this problem you must create a program that accepts a line of English text as input. The string may contain spaces, so make sure you read the entire line of input. Next your program should count the occurrences of each letter of the English alphabet and determine which letter occurs most frequently in the string. Print this letter to the screen. If two letters tie for the most frequent count, break the tie by choosing the letter that occurs first in the alphabet. For example if the input string was "aabb", then your program should identify 'a' as the most frequently occurring letter. Finally, remove all occurrences of this most frequently occurring letter by replacing them with the '-' character, and print the final string to the screen. HINT: Since ascii characters are stored as 8 bit ints "under the hood", and they are also represented in order (i.e. 'a' comes before 'b'); we can use them both as characters as well as for counting. Thus if we wanted to loop through all of…
in C++ please For this problem you must create a program that accepts a line of English text as input. The string may contain spaces, so make sure you read the entire line of input. Next your program should count the occurrences of each letter of the English alphabet and determine which letter occurs most frequently in the string. Print this letter to the screen. If two letters tie for the most frequent count, break the tie by choosing the letter that occurs first in the alphabet. For example if the input string was "aabb", then your program should identify 'a' as the most frequently occurring letter. Finally, remove all occurrences of this most frequently occurring letter by replacing them with the '-' character, and print the final string to the screen. Sample Input aaaab Sample Output a ----b Simplifying Assumptions You may assume that all letters are lowercase You only need to count the letters of the alphabet (i.e. don't worry about counting special characters like punctuation,…
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY