Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Programming Logic and Design (4th Edition)
4th Edition
ISBN: 9780133985078
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
The Print Statement takes a list of elements to print, separated by commas. IF the element is a string, THEN _____.  a. None of the above  b. Print the value associated with the variable  c. Print it as is  d. Print the result of performing the calculation
#include<iostream>#include<string.h>using namespace std; struct student{    int number;    string name;    int age;    string city;}s[10]; struct module{    int number;    string name;    string code;    int credit;}m[10]; struct assessment{    int number;    int marks1;    int marks2;}a[10]; int index1 =0, index2=0, index3=0; void StudentRegistration(){    if(index1==10)    {        cout<<"No more data can be added"<<endl;        return;    }    string temp;    cout<<"Enter personal data"<<endl;    cout<<"Enter Student Number"<<endl;    cin>>s[index1].number;    cout<<"Enter Student Name"<<endl;    getline(cin, temp);    getline(cin,s[index1].name);    cout<<"Enter Age"<<endl;    cin>>s[index1].age;    cout<<"Enter city"<<endl;    getline(cin,temp);    getline(cin,s[index1].city);    index1++;} void ModuleEnrolment(int id){    if(index2==10)    {        cout<<"No more data can be…
What will the following program segments display?A) for (int count = 0; count < 6; count++)cout << (count + count);B) for (int value = −5; value < 5; value++)cout << value;C) int x;for (x = 5; x <= 14; x += 3)cout << x << endl;cout << x << endl;

Chapter 12 Solutions

Starting Out with Programming Logic and Design (4th Edition)

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,