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
Question
Book Icon
Chapter 12.2, Problem 12.1CP
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”.

Blurred answer
Students have asked these similar questions
Option #1: String Values in Reverse Order Assignment Instructions Write a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the string values in reverse order. The function is to be called from the main method. In the main method, prompt the user for the three strings.
C++ Programming: Please view the following code statement. What is the final value of the variable "number"? int number = 5; number = 10; number = 100;
The following declaration, program, and program segment has errors. Locate as many as you can. struct Values {     string name;       int age; }

Chapter 12 Solutions

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

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning