Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
5th Edition
ISBN: 9780134801155
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 12.2, Problem 12.2CP
Program Plan Intro

Character by character text processing:

  • Strings can be accessed or manipulated by using an individual text that is present.
  • Different programming language access the string individually in a different way, some prefer the string gets accessed through subscript notation.
  • String is considered as list of characters.

Accessing string using subscript notation:

  • The string that are accessed using the subscript notation uses subscript “0” to hold the first character and similarly till the last character.
  • The last character of the string will be “\0”.
  • The first value the index value will be “0” and to find the last character use “length(variable)-1”

Example:

//declare and define a string

Declare String txt = "Hai"

Explanation:

In the above declaration, the given string  gets processed in the following way:

txt[0] will hold “H”.

txt[1] will hold “a”.

txt[2] will hold “i”.

Changing the occurrence of the string value that is declared:

  • Every value in the string gets accessed individually using the index or subscript value.
  •  In order to change the character located at a particular position, the index value can be used and it is made as shown below:

Example:

//set the value located at the position 0 as defined

Set txt[0]= “T”

Explanation:

The above line mentioned is used to replace or overwrite the content that is present at the first position.

The word “H” will be replaced with the word “T” for the string “txt” that is declared.

Blurred answer
Students have asked these similar questions
C sharp Write a method that accepts a string as an argument and checks it for proper capitalization and punctuation. The method should determine if the string begins with an uppercase letter and ends with a punctuation mark. The method should return true if the string meets the criteria; otherwise, it should return false.
When using a printf() statement, what syntax do you use to print the value of a "string"? %s %c %d %f
Assume mystring references a string. Write a statement that uses a slicing expression and displays the first 3 characters in the string.

Chapter 12 Solutions

Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Expressions in C++ | C++ tutorial for beginners; Author: Tutorial Mart;https://www.youtube.com/watch?v=XHbsZGpmRc8;License: Standard YouTube License, CC-BY
expression in python # python expressions; Author: Abhishek Tripathi;https://www.youtube.com/watch?v=Cc-kJGRjH6k;License: Standard Youtube License