Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8.2, Problem 17STE
Consider the following code:
string s1, s2 (“Hello”);
cout << “Enter a line of input: \n”;
cin >> s1;
if (s1 == s2)
cout << “Equal \n”;
else cout << “Not equal \n”;
If the dialogue begins as follows, what will be the next line of output?
Enter a line of input:
Hello friend!
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.
function isEven(num){ if(MISSING CONDITION){ return true; } else { return false; } }
A. num % 2 == 0;
B. num % 0 == 2;
C. num % 1 == 0;
D. num % 1 == 2;
c++language
Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:
"Hello! I'm Miley! Nice to meet you!"
1 #include
2 #include
3
4 void MakeSentenceExcited (char* sentenceText) {
/* Your solution goes here */
456700
8}
9
10 int main(void) {
11
12
13
14
const int TEST_STR_SIZE = 50;
char testStr[TEST_STR_SIZE];
fgets (testStr, TEST_STR_SIZE, stdin);
15 MakeSentenceExcited (testStr);
16 printf("%s", testStr);
17
10
notunna.
Chapter 8 Solutions
Problem Solving with C++ (10th Edition)
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...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
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
- Q3: By using Select-Case; write a program to calculate (BMI body mass index) (11 M) weight BMI = hieght And print the result as follows Underweight = 30arrow_forwardint const MULTIPLIER = 5; is a valid way to declare a constant integer variable. Group of answer choices True False ------- Given the following code segment, what is output to the screen? int num1 = 6; int num2 = 4 * num1++; cout << "num1=" << num1 << " num2=" << num2; Group of answer choices num1=7 num2=24 num1=6 num2=24 num1=6 num2=28 Nothing, because the code does not compile.arrow_forwardAssume that M is declared as int, and a value is stored in it. How would you check * ? whether N is between 3 and 9 if (M 9) // N is in valid range if (M > 3 && M 9) // N is in valid range if (M >= 3 || M = 3 &&N 100) cout100) cout>>'too many"; O if (count<100) cout<<"too many"; What will be displayed by the following segment of code? int option = 7: switch(option) (case 1: cout << "Purdue" << endl;break; case 2: cout << "Michigan" Ss endl:break: case 3: cout << "IU" << endl;break; default: cout << "IUPUI"arrow_forwardthis is output need to do in C codearrow_forwardIn CPP language.arrow_forwardGiven string inputString on one line, character userChar on a second line, and integer strIndex on a third line, output "Match found" if the character at index strindex of inputString matches userChar. Otherwise, output "Match not found". End with a newline. Ex: If the input is: write i 2 then the output is: Match found Note: Assume the length of string inputString is greater than strIndex. 1 import java.util.Scanner; 2 3 public class Matching Char { 4 5 7 8 9 10 11 12 13 14 15 16 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String inputString; char userChar; int strIndex; 3 inputString = scnr.nextLine(); userChar scnr.next().charAt(0); strIndex scnr.nextInt(); *Your code goes here */arrow_forwardQn1: You are asked to write a simple C program that will accept an integer value in the range of 5-95 and as a multiple of 5 representing the number of cents to give to a customer in their change. The program should calculate how many coins of each denomination and display this to the user. Valid coin values are 50, 20, 10 and 5. Your solution (program and algorithm) should be modular in nature. This requires the submission of a high-level algorithm and suitable decompositions of each step. Note that for this problem the principle of code reuse is particularly important and a significant number of marks are allocated to this. You should attempt to design your solution such that it consists of a relatively small number of functions that are as general in design as possible and you should have one function in particular that can be reused (called repeatedly) in order to solve the majority of the problem. If you find that you have developed a large number of functions which each performs…arrow_forwardlanguage is c++arrow_forwardGiven string inputString on one line and integers idx1 and idx2 on a second line, output "Match found" if the character at index idx1 of inputString is equal to the character at index idx2. Otherwise, output "Match not found". End with a newline. Ex: If the input is: banana 1 3 then the output is: Match found Note: Assume the length of string inputString is greater than or equal to both idx1 and idx2. import java.util.Scanner; public class CharMatch { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String inputString; int idx1; int idx2; inputString = scnr.nextLine(); idx1 = scnr.nextInt(); idx2 = scnr.nextInt(); /* Your code goes here */ }}arrow_forwardWrite a main function that performs the following: • Prompts user to enter 2 values A and B. . If the first number A is less than the second number B, the main function should print the sum of all numbers multiple of 2 from 1 to A. • If the first number A is greater than the second number B, the main function should print the product of all numbers multiple of 4 from 1 to B. • If not, the main function should display "Wrong data. Try again!".arrow_forwardIn C++ (Algebra: solve 2 × 2 linear equations) You can use Cramer’s rule to solve the following 2 × 2 system of linear equation: ax + by = ecx + dy = fx = (ed - bf) / (ad - bc)y = (af - ec) / (ad - bc) Write a program that prompts the user to enter a, b, c, d, e and f and displays the result. If ad - bc is 0, report that “The equation has no solution”. Sample Run 1 Enter a, b, c, d, e, f: 9.0 4.0 3.0 -5.0 -6.0 -21.0 x is -2 and y is 3 Sample Run 2 Enter a, b, c, d, e, f: 1.0 2.0 2.0 4.0 4.0 5.0 The equation has no solutionarrow_forward10. Given the following variables, for each problem, determine what will be printed on the screen when the code is executed. If there is an error, say what the error is. numl = 4 num2 = 13.0 tf = False if num2 > 5: e. if tf num2 > numl: а. == print ("Big") print ("this tf:", tf) ww" wwww else: else: print ("Small") print ("that tf:", tf) www" b. if numl 5: f. tf = True www print ("Message 1") if tf == num2 > numl: else: print ("this tf:",tf) www print ("Message 2") else: print ("that tf:",tf) www if numl = 5: c. print ("Message 1") g. tf = "True" www else: if tf == num2 > numl: print ("Message 2") print ("this tf:",tf) else: print ("that tf:",tf) www d. if num2 > numl: print ("Tom") if not tf: www print ("Harry")arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Algebraic Expressions – Algebra Basics; Author: TabletClass Math;https://www.youtube.com/watch?v=U-7nq7OG18s;License: Standard YouTube License, CC-BY
Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions; Author: ProgrammingKnowledge;https://www.youtube.com/watch?v=Os4gZUI1ZlM;License: Standard Youtube License