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

Question
Book Icon
Chapter 12, Problem 4SA
Program Plan Intro

Character testing library functions:

  • Library functions other than the string library functions are provided by programming language, which are intended to work with single characters.
  • The support library functions are used for testing the value of the character.
  • The function will return the Boolean result on testing; the result will be in “True” or “False” format.

isUpper(character):

  • This function is used to validate whether the character given is upper case letter.
    • The function will return “True” if the character is in upper case.
    • The function will return “False” if the character is in lower case.

isLower(character):

  • This function is used to validate whether the character given is lower case letter.
    • The function will return “True” if the character is in lower case.
    • The function will return “False” if the character is in upper case.

Example:

The below algorithm determines whether the first character in the string is in upper case and the present is in upper case, the character gets replaced by “0”.

//determine if the first character is in upper case

If isUpperCase (str[0]) Then

//replace the values present at the first position

Set str [0] = "0"

//end if

End If

Explanation:

  • If condition validates the first position of the “str” is in upper case or not.
  • If the condition becomes true, the character at positon “0” gets replaced with the character “0”.

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 first value the index value will be “0” and to find the last character use “length(variable)-1”.
  • When a string is tried to access using an invalid subscript, it will throw an error.

Analysis of the given statement:

//declare and define a string

Declare string str= “Might”

//set the value located at the subscript 5 as defined

Set str[5] = “y”

Blurred answer
Students have asked these similar questions
Write a C++ (visual studio) program that examines a list of numbers to find the smallest value. The list should include 10,000 random whole numbers that range from -1,000,000 to 1,000,000. The program should display the lowest value in the list and the number of the element that contains that value.And create a pseudocode explaining the steps. (if you would give to someone to create the program) The program must have:Declare an array in the main() function that will hold 10,000 integers. Pass the array to the other functions as necessary. Use a reliable algorithm to produce random integers within a given range. Note: stran()/rand() is NOT a reliable random number algorithm. The function should accept the minimum and maximum values that will be generated and return an integer.Examine the array to find the smallest value. Return the smallest value and the number of the element that contains the smallest value.
JAVA CODE PLEASE FINAL EXAM Part 3 Instructions: Create a java program that asks & accepts input from the user (must be int value). Then depending on the number of inputs, the program will ask the user to enter string value/s. After, the program will print the strings entered by the user line-by-line. Constraints: Create a function and call it in the main function. Use Functions With No Parameters and Return Values Use for Loop Use String Array Use Scanner Input 1. One line containing an integer Sample 2 2. One line containing string Sample Funny 3. One line containing string Sample Sadly Output Enter·the·number·of·string·array:·2 Enter·string·#1:·Funny Enter·string·#2:·Sadly You've·entered: Funny Sadly
char lastChar(const char *str){    char last;    //loop over the string and go uptill end of the string \0    while(*str !='\0'){        str++; // increment pointer        last = *str;  //store the current character to the last variable    }        return last; //last character is returned}

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
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,