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 7PP
Program Plan Intro

Program Plan:

Following variables are used in the program:

name: To store the string name entered by user.

firstName, middleName, lastName: To store the first name, middle name and last name of string name entered by user.

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 string.

cout: used to display output to the console.

Summary Introduction:

Program will use 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.

Blurred answer
Students have asked these similar questions
In C language, Write a function that gets a string containing a positive integer. The function subtracts 1 fromthat integer and puts the obtained value in the string. void str_subtract_one(char* num); For example:- if before we call str_subtract_one(str) we have str==“1997”, then after return str will be “1996”.- if before we call str_subtract_one(str) we have str==“12345678987650”, then after return str will be “12345678987649”.- if before we call str_subtract_one(str) we have str==“100”, then after return str will be “99”. 1. You may assume that the input is always legal, i.e., the string is a positive integer correctly formatted.2. Note that the numbers may be larger than the maximum of int or long. That is, you should not try to convert string to int
Write a C++ program in Microsoft Visual Studio 2019, use only strings and functions. You need to create a game using strings. First generate a random letter from A to Z, this is your key and is hidden from the players.   Ask player1 and player 2 to enter two strings of length 10.   The player whose strings contains the key alphabet will win.   If both the players have key alphabets, then the player for which it occurs earlier in the string will win.   Sample Input: As computer generate a random letter such as Key: S (This Key must not be visible to user ) After that player1 enter this input in string. Player1: ABDXSCJMNK; And player2 enter this input in string Player2: CSTUZWKMIJ Sample output: Player 2 wins.
In C Write a program to take a product code from Millie’s Mail- Order Catalog (MMOC) and separate it intoits component parts. An MMOC product code begins with one or more letters identifying the warehouse where the product is stored. Next come the one or more digits that are the product ID. The final field of the string starts with a capital letter and represents qualifiers such as size, color, and so on. For example, ATL1203S14 stands for product 1203, size 14, in the Atlanta warehouse. Write a program that takes a code, finds the position of the first digit and of the first letter after the digits, and uses strcpy and strncpy to display a report such as the following: Warehouse: ATL Product: 1203 Qualifiers: S14
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
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges; Author: FreecodeCamp.org;https://www.youtube.com/watch?v=oBt53YbR9Kk;License: Standard YouTube License, CC-BY