Problem Solving With C++ (Looseleaf) - With Access
9th Edition
ISBN: 9780133835267
Author: SAVITCH
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 8.1, Problem 11STE
What string will be output when this code is run? (Assume, as always, that this code is embedded in a complete, correct
char song[10] = “I did it”;
char franksSong[20];
strcpy(franksSong, song );
strcat( franksSong, “my way!”);
cout << franksSong << endl;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include <iostream>using namespace std;
bool isThere(string s, char c, int si, int ei){ //return true if char c is present in s at index in range [si,ei] //return false otherwise //you can assume 0<=si<=ei<s.length() //write your code here }int main(){ //write code here to test the function return 0;}
Alter your program such that it will identify a target String within another String. Prompt the user for a String. Then prompt the user for a target String. Your program should find each occurrence of that target string in the other String. If the target string is not contained in the other string indicate that to the user. For each occurrence of the target string contained in the other String, display the starting index of the target string, the ending index of the target string, the ASCII character preceding the target string, the ASCII character following the target string. You must find strings that differ only in case.
Place this code inside a do-while loop and allow the user to repeat it as many times as they would like.
submit your program as an Eclipse .zip project
Example of what the program might look like running.
This program identifies if a target String is contained within anoteher String.And, if it is there it returns the first occurence of that String.It also…
Assume that nextWord is a String variable that has been given a String value consisting entirely of letters. Write some Java code that outputs the message "First half of the alphabet", provided nextWord precedes "N" in alphabetic ordering. If nextWord does not precede "N" in alphabetic ordering, the code should output "Second half of the alphabet". (Note that "N" uses double quotes to produce a String value, as opposed to using single quotes to produce a char value.)
Chapter 8 Solutions
Problem Solving With C++ (Looseleaf) - With Access
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
These characters serve specific purposes, such as marking the beginning or ending of a statement, or separating...
Starting Out with Java: Early Objects (6th Edition)
How is a constructor used?
Starting out with Visual C# (4th Edition)
How do you find runtime and logic errors in a program?
Starting Out With Visual Basic (7th Edition)
Why is the computer used by so many different people, in so many different professions?
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
Suppose you need to write a program that stores a fixed number of the elements (possibly duplicates), what data...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Knowledge Booster
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
- Fibonacci’s sequence starts with values 1 and 1. The next value in the sequence is formed by summing the previous two values. Thus the third value is 1+1=2, the fourth is 1+2=3, the fifth is 2+3=5, etc. Thus, the sequence is 1, 1, 2, 3, 5, 8, 13, 21, …. Write a code fragment using c++ that obtains a positive integer n from the user and displays the sum of the first n numbers in the Fibonacci sequence. If n is not positive, use cout to print out an error message. Put this code fragment in your main() of your project.arrow_forwardSuppose the following problem statement is given to you and you are planning to write a code for this problem. Problem statement: Let str be a string that contains any number of lower case letters from this set {a, b, c, .. z}. Samples of some valid str's are aabddd, bttttccd, cafffffgggaat etc. Your program must validate the input (check whether it contains only lowercase letters) and create and print a new string (a copy of str) such that all repeated letters in str are replaced by the number of repeats followed by just one letter, i.e., aa will be replaced by 2a, bbb will be replaced by 3b, etc. Other (non-repeated) letters will remain same, For invalid inputs your program must generate an error message. Some sample strings and the expected outputs are as follows. Sample str = aabddd, expected output = 2ab3d Sample str = bttttccd, expected output = b4t2cd Sample str = caffgggaat, expected output = ca2f3g2at Sample str = caffgggaat, expected output = ca2f3g2at Sample str =…arrow_forwardPlease explain Python code import random# 1) write a procedure that takes a string # and uses a loop to print out each character, # one character per line.def spitoutchars(word):#for c in word:# print(c)#for c in range(len(word)):# print(word[c])#for c in range(0,len(word),1):# print(word[c])c = 0 # start of the rangewhile c < len(word): # < end of the rangeprint(word[c])c += 1 # add the incrementdef rspitoutchars(word):# print out first letter# recurse on string w/o first letter until... string is emptyprint(word[0])word = word[1:] # cut off first letterif len(word) != 0:rspitoutchars(word)arrow_forward
- Please fill in the blanks in C. /* Copy Strings Backward Input String1: Hello World*/ /* We’ll initialize a string (I’ll use “Hello World”). Then, create a second string and copy the first string over, but backwards, using a loop. Print both strings. For example: string 1 is “Hello World”, string 2 would be “dlroW olleH”. */ #include<stdio.h> #define str_len __1__ //str_len = hello + space + world + null char LEN __2__ print_string(__3__ str[__4__]); __5__ copy_string(__6__ s1[__7__], __8__ s2[__9__]); int main() { __10__ str1[]= "Hello World"; __11__ str2[__12__]; //loop and copy each character over // until the array reaches null character copy_string(__13__, __14__); //printing back by calling function print_string printf("String1: "); print_string(__15__); printf("\nString2: "); print_string(__16__); } /*Copy one string to another by…arrow_forwardPlease explain Python Code # 2) Write a procedure that takes a string and returns that string ROT13'ed.def rot13(word):encryptedword = ""for c in word:if c >= 'a' and c <= 'm': # a..mencryptedword += chr((ord(c)+13))elif c >= 'n' and c <= 'z': # n..zencryptedword += chr((ord(c)-13))else: # don't encrypt lettersencryptedword += creturn encryptedword#print(rconvertup("example"))print(rot13("example!"))print(rot13(rot13("example!")))arrow_forwardCODE USING C++ Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong". It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct. Now, will you take on this task? Input A line containing four one-letter strings separated by a space. c·O·D·y Output A line containing a string. Correctarrow_forward
- is it correct ? Write a function to count how many numbers in one string.. Answer: #include <iostream> #include <string> using namespace std; int countNumbers(string str) { int count = 0; for (char c : str) { if (isdigit(c)) { count++; } } return count; } int main() { string str = "Hello, World, 00000"; cout << countNumbers(str) << endl; return 0; }arrow_forwardWhat will be the output of code given below.#include <iostream>using namespace std; int main(){int n=12;while(n--){cout<<"C++ is successor of C."<<endl;} return 0;}arrow_forwardThis is in c++ 1. Prompt the user to enter a string of their choosing and output the string. 2. Complete the GetNumOfCharacters() function, which returns the number of characters in the user's string. Encouraged to use a for loop. 3. In main(), call the GetNumOfCharacters() function and then output the returned result. 4. Implement the OutputWithoutWhitespace() function. OutputWithoutWhitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the OutputWithoutWhitespace() function in main(). My issue is deleting the spaces. I googled how to delete spaces, but there are terms I haven't learned yet. I'm not sure how to delete the spaces. This is what I have: #include <iostream>#include <string>using namespace std; //Returns the number of characters in usrStrint GetNumOfCharacters(const string usrStr) {int count = 0;unsigned int i;for (i = 0; i < usrStr.size(); ++i) {++count;}return count;} void…arrow_forward
- c languge Write a code that will do the following in order: 1- Take two strings from the user: s1 and s2 2- Compare the two strings and concatenate them such that the alphabetically first one goes first: Ex: Run 1: s1: Amy s2: Bruder Result: Amy Bruder Run 2: s1: Baby s2: Ahoy Result: Ahoy Babyarrow_forwardshort answers : c)Give an example of a common floating point arithmetic error due to the particular way in which floating point numbers are stored? d)Give an example of how when using C-strings and the functionstrcpy, things can go wrong.arrow_forward// Task 2 // For this function, you must build a string that when printed,// will output the entire binary representation of the integer x,// no matter how many bits an integer is. You may NOT use// division (/) or mod (%) anywhere in your code, and should// instead rely on bitwise operations to read the underlying binary// representation of x.stringbuilder get_bin_1(int x) { stringbuilder sb = new_sb(); sb_append(sb, '$'); return sb;}arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY