Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 10, Problem 1PC
Program Plan Intro
String Length
- Include the required header files to the program.
- Declare function prototype which is used in the program.
- Define the “main()” function.
- Declare the required variables.
- Get the input string from the user and call the function “string_length”.
- Define the “string_length” function.
- Declare the variable.
- The “while” loop is used to check the length of the string.
- Finally return the length of the string to the main function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
3. Word Counter
Write a function that accepts a pointer to a C-string as an argument and returns the
number of words contained in the string. For instance, if the string argument is "Four
score and seven years ago" the function should return the number 6. Demonstrate the
function in a program that asks the user to input a string then passes it to the func-
tion. The number of words in the string should be displayed on the screen. Optional
Exercise: Write an overloaded version of this function that accepts a string class
object as its argument.
Exercise #3: Character Counts
Write a c++ program that prompts the user to enter a string, calls the function lowerUpperDigits( ) which takes a string and counts the number of lower, upper, and digit characters in the string. The main program prints the number of found characters.
int lowerUpperDigits(string, int&, int&);
Sample input / output:
A string is passed as argument to a function named hS, the function also returns a string which is the first half of the string given as argument, i.e. from index 0 to l/2 where l is the length of the string.
Language: C++
Chapter 10 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 10.2 - Write a short description of each of the following...Ch. 10.2 - Prob. 10.2CPCh. 10.2 - Write an if statement that will display the word...Ch. 10.2 - What is the output of the following statement?...Ch. 10.2 - Write a loop that asks the user Do you want to...Ch. 10.4 - Write a short description of each of the following...Ch. 10.4 - Prob. 10.7CPCh. 10.4 - Prob. 10.8CPCh. 10.4 - Prob. 10.9CPCh. 10.4 - When complete, the following program skeleton will...
Ch. 10.5 - Write a short description of each of the following...Ch. 10.5 - Write a statement that will convert the string 10...Ch. 10.5 - Prob. 10.13CPCh. 10.5 - Write a statement that will convert the string...Ch. 10.5 - Write a statement that will convert the integer...Ch. 10.6 - Prob. 10.16CPCh. 10 - Prob. 1RQECh. 10 - Prob. 2RQECh. 10 - Prob. 3RQECh. 10 - Prob. 4RQECh. 10 - Prob. 5RQECh. 10 - Prob. 6RQECh. 10 - Prob. 7RQECh. 10 - Prob. 8RQECh. 10 - Prob. 9RQECh. 10 - Prob. 10RQECh. 10 - The __________ function returns true if the...Ch. 10 - Prob. 12RQECh. 10 - Prob. 13RQECh. 10 - The __________ function returns the lowercase...Ch. 10 - The _________ file must be included in a program...Ch. 10 - Prob. 16RQECh. 10 - Prob. 17RQECh. 10 - Prob. 18RQECh. 10 - Prob. 19RQECh. 10 - Prob. 20RQECh. 10 - Prob. 21RQECh. 10 - Prob. 22RQECh. 10 - Prob. 23RQECh. 10 - Prob. 24RQECh. 10 - The ________ function returns the value of a...Ch. 10 - Prob. 26RQECh. 10 - The following if statement determines whether...Ch. 10 - Assume input is a char array holding a C-string....Ch. 10 - Look at the following array definition: char...Ch. 10 - Prob. 30RQECh. 10 - Write a function that accepts a pointer to a...Ch. 10 - Prob. 32RQECh. 10 - Prob. 33RQECh. 10 - T F If touppers argument is already uppercase, it...Ch. 10 - T F If tolowers argument is already lowercase, it...Ch. 10 - T F The strlen function returns the size of the...Ch. 10 - Prob. 37RQECh. 10 - T F C-string-handling functions accept as...Ch. 10 - T F The strcat function checks to make sure the...Ch. 10 - Prob. 40RQECh. 10 - T F The strcpy function performs no bounds...Ch. 10 - T F There is no difference between 847 and 847.Ch. 10 - Prob. 43RQECh. 10 - char numeric[5]; int x = 123; numeri c = atoi(x);Ch. 10 - char string1[] = "Billy"; char string2[] = " Bob...Ch. 10 - Prob. 46RQECh. 10 - Prob. 1PCCh. 10 - Prob. 2PCCh. 10 - Prob. 3PCCh. 10 - Average Number of Letters Modify the program you...Ch. 10 - Prob. 5PCCh. 10 - Prob. 6PCCh. 10 - Name Arranger Write a program that asks for the...Ch. 10 - Prob. 8PCCh. 10 - Prob. 9PCCh. 10 - Prob. 10PCCh. 10 - Prob. 11PCCh. 10 - Password Verifier Imagine you are developing a...Ch. 10 - Prob. 13PCCh. 10 - Word Separator Write a program that accepts as...Ch. 10 - Character Analysis If you have downloaded this...Ch. 10 - Prob. 16PCCh. 10 - Prob. 17PCCh. 10 - Prob. 18PCCh. 10 - Check Writer Write a program that displays a...
Knowledge Booster
Similar questions
- PYTHON Problem Statement Implement a function which takes two arguments: the first is a string and the second is a single character (as a string). This function should move every instance of the given character in the string to the end of the string, and then return (do NOT print) the final string. NOTE: Only write code within the function. You do not need to utilize the "input()" function. The autograder passes inputs directly to the function as arguments, and the checked output is the returned value from the function. Sample Input "hello how are you?", "o" Sample Output "hell hw are yu?ooo" Starter Code def move_character(word, character):arrow_forwardProgramming language: SWIFT Write a function that takes a string as a parameter and returns the string "Swift" if the string passed as parameter begins with "SWIFT" or "swift". Otherwise, returns an empty string.arrow_forwardC++ Language: Write a Python program to take input string str from the user and form a new string newstr that contains the first three and last three characters of string str. It is given that the length of str is always greater than 6.arrow_forward
- C++ - Vowels and Consonantsarrow_forwardIn C programming language Question (Strings) Write a function find_Substring() that finds a substring into a string. Pass array s1 and s2 to this function and prints if the substring is present or not. Expected Output 1: Enter string This is a javascript Enter substring script The substring is present Expected Output 2: Enter string This is a javascript Enter substring Jscript The substring is not presentarrow_forwardIn C programming, write a function that accepts a character argument and returns 1 if the argument is a valid letter(a-z/A-Z), otherwise returns 0.arrow_forward
- Code must be in C++arrow_forward// write a function that takes the input string and reverses it// example// argument: Hello// return: olleHfunction reverseThisString(string){ } // write a function that takes the input string and switches all uppercase characters to lowercase and lowercase charcaters to uppercase// example:// argument: Hello World// return: hELLO wORLDfunction swapCase(string) { } //convert array of numbers from farenheit to celcius// example:// argument: [23, 32, 41, 50, 59]// return: [-5, 0, 5, 10, 15]// hint: use Array.mapfunction toCelcius(array){ } //write a function that takes an input array and returns an array of booleans (>=75) or fail (<75)// example:// argument: [20, 30, 50, 80, 90, 100]// return: [false, false, false, true, true, true]// hint: use Array.mapfunction passOrFail(array){ } //write code that loops through the two variables returns an array ['2 is zwei', '3 is drei', '4 is vier', '5 is fünf', '6 is sechs']// example:// return: ['2 is zwei', '3 is drei', '4 is vier', '5 is…arrow_forwardC++ Write a program that first asks the user to enter a string and then asks the user to enter a character. The program should display the number of times the character appears in the string. Use the function Count_char(). A function Count_char() that has two arguments. The first argument is an array and the second argument is a character. The function returns an integer.arrow_forward
- C Program Functions with Parameters and No Return Values Create a function named palindrome that asks the user a string input if called. If the string is a palindrome, print “{input} is a palindrome!”, otherwise print “{input} is not a palindrome!” In the main function, call the palindrome function. Input 1. One line containing a single string Output Enter a string: racecar racecar is a palindrome!arrow_forwardC++ Visual studio 2019 - Vowels and Consonants - Just do everything in main and make sure you comment each step Make sure to use namespace stdarrow_forwardPython task You must write a function control (p_nr) that calculates and returns the control digit in a 10-digit social security number if you send in the first 9 digits in the form of a string. The rules for calculating the check digit in a social security number are as follows:The numbers are multiplied alternately by 2 and 1 and then the products are summed. For a two-digit product, the sum of its numbers is calculated. The sum is then subtracted from the nearest higher tens to obtain the check digit.To calculate the check digit for the social security number with the first 9 digits 811218987, perform the following setup: 8 1 1 2 1 8 9 8 7 2 1 2 1 2 1 2 1 2 16 1 2 2 2 8 18 8 141 + 6 + 1 + 2 + 2 + 2 + 8 + 1 + 8 + 8 + 1 + 4 = 44The check digit is 50-44 = 6 # test personal_number = input () control_digit = control(personal_number) print(control_digit)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage