Starting Out with Programming Logic and Design (4th Edition)
4th Edition
ISBN: 9780133985078
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 12, Problem 5MC
Program Description Answer
Analysis of the given statement:
- A variable name is declared and defined.
- Character at subscript “4” needs to be replaced with the character “y”.
Explanation:
- The given statement will throw an error because it is trying to access with an invalid subscript of the string.
Hence, the correct answer is option “A”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
I keep getting these errors when I run the code below: Code is in C++
____animal.cpp_______
#include "animal.h"Animal::Animal(){}Animal::Animal(string name,string gender, string color, double weight){this->name = name;this->gender = gender;this->color = color;this->weight = weight;}void Animal::PrintInfo(){cout<<"Name : "<<name<<endl;cout<<"Gender : "<<gender<<endl;cout<<"Color : "<<color<<endl;cout<<"Weight : "<<weight<<endl;}
__animal.h___
#ifndef __ANIMAL_H#define __ANIMAL_H#include<iostream>using namespace std;class Animal{private:double weight;string name;string gender;string color;public:Animal();Animal(string,string , string, double);virtual void PrintInfo();};#endif
___horse.h___
#ifndef __HORSE_H#define __HORSE_H#include "animal.h"
class Horse : public Animal{private:string breed;int id;string comments;public:Horse();Horse(string,double,string,string,int,string,string);void…
Hete_matching the code EXACTLY how it is below, etc.).
Fix the errors and find the lowest marks entered by the user
struct std{string name;int reg_no;int marks[5];}s1;getline(cin,s1.name);cin>>s1.reg_no;for(int i =0;i<5;i++)cin>>s1.marks[i]
Chapter 12 Solutions
Starting Out with Programming Logic and Design (4th Edition)
Ch. 12.2 - Prob. 12.1CPCh. 12.2 - Prob. 12.2CPCh. 12.2 - Design an algorithm that determines whether the...Ch. 12.2 - Design an algorithm that determines whether the...Ch. 12.2 - Prob. 12.5CPCh. 12.2 - Prob. 12.6CPCh. 12 - Prob. 1MCCh. 12 - Prob. 2MCCh. 12 - If the str variable contains the string "berry",...Ch. 12 - If the str variable contains the string "Redmond",...
Ch. 12 - Prob. 5MCCh. 12 - Prob. 1TFCh. 12 - Prob. 2TFCh. 12 - If the String variable str contains the string...Ch. 12 - The insert library module automatically expands...Ch. 12 - Prob. 5TFCh. 12 - Prob. 6TFCh. 12 - Prob. 7TFCh. 12 - Prob. 1SACh. 12 - If the following pseudocode were an actual...Ch. 12 - Prob. 3SACh. 12 - Prob. 4SACh. 12 - Prob. 5SACh. 12 - Design an algorithm that counts the number of...Ch. 12 - Prob. 2AWCh. 12 - Design an algorithm that counts the number of...Ch. 12 - Design an algorithm that deletes the first and...Ch. 12 - Design an algorithm that converts each occurrence...Ch. 12 - Design an algorithm that replaces each occurrence...Ch. 12 - Assume the following declaration exists in a...Ch. 12 - Prob. 1DECh. 12 - Prob. 2DECh. 12 - Prob. 3DECh. 12 - Prob. 1PECh. 12 - Sentence Capitalizer Design a program that prompts...Ch. 12 - Prob. 3PECh. 12 - Sum of Digits in a String Design a program that...Ch. 12 - Prob. 5PECh. 12 - Alphabetic Telephone Number Translator Many...Ch. 12 - Word Separator Design a program that accepts as...Ch. 12 - Pig Latin Design a program that reads a sentence...Ch. 12 - Prob. 9PECh. 12 - File Encryption File encryption is the science of...Ch. 12 - File Decryption Filter Design a program that...
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
- What will the following Code segment print on the screen? String LName = "FamilyName"; String FName = "GivenName"; System.out.println("Dear Mr " + LName); System.out.println("We would like to call you " + FName);arrow_forwardPlease provide a flowchart for this question(pseudocode is acceptable) Finding Missing Number: Given a set of numbers in the range [0, n]. -Only 1 number is missing from the array. -Find the missing number? Note: The number in a set is not sorted Please note: that I am not asking for the actual code for this question but just the flowchartarrow_forwardThe following statement will declare a one-dimensional String array. What is the subscript for the first element? Dim strLakes(5) As String a. 5 b. 6 c. 0 d. 1arrow_forward
- In the code segment Double radius = 4.5; Const double* ptr = & radius;The ptr is constant, but the data pointed to by the pointer ptr is not constant options: True Falsearrow_forward#include<iostream> using namespace std; string name; int number; int age; string city; string module1_name; string module1_code; int module1_credit; string module2_name; string module2_code; int module2_credit; int module1_marks; int module2_marks; void student_registration() { cout<<"\nEnter Student ID: "; cin>>number; cout<<"\nEnter Student's name : "; cin>>name; cout<<"\nEnter age : "; cin>>age; cout<<"\nEnter city : "; cin>>city; } void module_enrolment() { cout<<"\nEnter Module1 name : "; cin>>module1_name; cout<<"\nEnter Module1 code : "; cin>>module1_code; cout<<"\nEnter Module1 credits : "; cin>>module1_credit; cout<<"\nEnter Module2 name : "; cin>>module2_name; cout<<"\nEnter Module2 code : "; cin>>module2_code; cout<<"\nEnter Module2…arrow_forwardWhat will the following code display? mystring = 'abcdefg' print(mystring[:])arrow_forward
- The local taqueria now wants some help with their kitchen system. There are four types of burritos: carnitas, beef, shrimp, and vegetarian. They would like you to create a program to send an alert to the kitchen if there is a shrimp burrito in a given order. Your main() function should prompt the user for the number of burritos in the order, and then enter all the burrito types for the order. The burrito types should be stored in an array of strings. You'll also need to store the number of burritos in the order. You can assume that no order will have more than 10 burritos. You can assume that the user only types in valid types of burritos, e.g. carnitas, beef, shrimp, vegetarian. The shrimp burrito must be cooked to order and thus takes longer to prepare than the other kinds. Because of this, an alert is needed ASAP if there is a shrimp burrito in the order. Write a function which takes two parameters: your array of burrito strings, and the number of burritos in the array.…arrow_forwardThis code prompts the user for input to create a Mad Lib,converts the Mad Lib to uppercase, finds the number of timesthe word 'a' appears in the Mad Lib, finds the unique words in the Mad Lib using sets, and checks if a specific word isin the Mad Lib using an if condition.'''import datetime # Get user inputname = input("Enter a name: ")adjective = input("Enter an adjective: ")verb1 = input("Enter a verb: ")verb2 = input("Enter another verb: ")noun1 = input("Enter a noun: ")noun2 = input("Enter another noun: ")animal = input("Enter an animal: ")food = input("Enter a food: ")fruit = input("Enter a fruit: ")superhero = input("Enter a superhero name: ")country = input("Enter a country name: ")dessert = input("Enter a dessert: ")year = datetime.datetime.now().year # Create a Mad Lib with the user inputmad_lib = f"{name} was a {adjective} person who loved to {verb1} and {verb2}. One day, {name} found a {animal} in their {noun1}. " \ f"They decided to take the {animal} to the {noun2}…arrow_forwardThe last part of this code I need the "cans" to be a whole number. I don't know how to change it What I have right now below: #include <iostream>#include <cmath> // Note: Needed for math functions in part(3)#include <iomanip> // For setprecisionusing namespace std; int main(){double wallHeight;double wallWidth;double wallArea; cout << "Enter wall height (feet):" << endl;cin >> wallHeight; // FIXME (1): Prompt user to input wall's widthcout << "Enter wall width (feet):" << endl;cin >> wallWidth; // Calculate and output wall areawallArea = wallHeight * wallWidth; // FIXME (1): Calculate the wall's area cout << fixed << setprecision(2) << "Wall area: " << wallArea<< " square feet" << endl;// FIXME (1): Finish the output statement // FIXME (2): Calculate and output the amount of paint in gallons needed to//paint the wallcout << fixed << setprecision(2) << "Paint needed: " <<…arrow_forward
- Template below: include <iostream>#include <cmath> // Note: Needed for math functions in part (3)#include <iomanip> // For setprecisionusing namespace std; int main() {double wallHeight;double wallWidth;double wallArea;cout << "Enter wall height (feet):" << endl;cin >> wallHeight;wallWidth = 10.0; // FIXME (1): Prompt user to input wall's width// Calculate and output wall areawallArea = 0.0; // FIXME (1): Calculate the wall's areacout << "Wall area: " << endl; // FIXME (1): Finish the output statement// FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall // FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer return 0;}arrow_forwardEvery line of this c program please explain. Thank you Source Code: // include necessary header files# include<stdio.h># include<time.h># include<stdlib.h> int main(){ // Use current time as seed srand(time(0)); // declare variables int arr[5][5] = {0}, user_num[5] = {0}, k = 1, i, j; int num[75] = {0}, n, flag, count, winner = 0; // initialize num array for(i = 0; i < 75; i++) num[i] = k++; // initialize the array cell with random numbers for(i = 0; i < 5; i++){ for(j = 0; j < 5; j++){ while(1){ // generate random numbers n = rand() % 75; if(num[n] != 0){ arr[i][j] = n + 1; num[n] = 0; break;…arrow_forwardWhat will the following code display?mystring = 'abcdefg'print(mystring[3:])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