Write a c++ function named "analyze" that accepts an array of characters terminating by a NULL character (C-string). It will return the following info to the caller through the return type and parameters: the number of blanks, digits, uppercase and lowercase characters. For example, if this function is called with this passed array of {'H', 'e', 'l', 'l', 'o', ' ', '0', '1', '2', '3', '!', '\0'}, it will return 1 for the number of uppercase charactes, 4 for the number of lowercase characters, 1 for the number of blank, and 4 for the number of digits.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 Please do not include and use string class. The function is using only array notation and manipulation.
- string functions such as strlen is not allowed.
- it should not have multiple return statements in the same function
- there should be no global variable.
- the function should not traverse the arrays more than once (e.g. looping through the array once only)

  1. Write a c++ function named "analyze" that accepts an array of characters terminating by a NULL character (C-string). It will return the following info to the caller through the return type and parameters: the number of blanks, digits, uppercase and lowercase characters.
    For example, if this function is called with this passed array of {'H', 'e', 'l', 'l', 'o', ' ', '0', '1', '2', '3', '!', '\0'}, it will return 1 for the number of uppercase charactes, 4 for the number of lowercase characters, 1 for the number of blank, and 4 for the number of digits.
  2. Write a c++ function named "swapTheFirstTwoWithTheLastTwo" that accepts an array of integers and its size. If the array has 4 or more elements, it will swap the first two elements with the last two elements in the array.

    For example, if it is called with the array of {10, 20, 30, 40}, it will swap to become {30, 40, 10, 20}.
    If it is called with the array of {10, 20, 30, 40, 50}, it will swap to become {40, 50, 30, 10, 20}.
    If it is called with the array of {10, 20, 30}, it will not swap and the array remains the same.

  3. Write a c++ function named "isTheLastNumberTheMax" that accepts an array of integers and its size. It will return true if the last number in the array is the maximum number in that array and false otherwise. In addition, it also returns another boolean to indicate whether this list contains more than one maximum value.
    For example, if this is called with the array of {10, 20, 30, 40, 50}, it will return true and false
    If this is called with the array of {50, 10, 20, 30, 40, 50}, it will return true and true.
  4. Write a c++ function named "changeCase" that takes an array of characters terminating by NULL character (C-string) and a boolean flag of toUpper. If the toUpper flag is true, it will go through the array and convert all lowercase characters to uppercase. Otherwise, it will convert all uppercase to lowercase.

    For example, if the array is {'H', 'e', 'l', 'l', 'o', '\0'} and the flag is true, then the array will become
    {'H', 'E', 'L', 'L', 'O', '\0'}. And if the flag is false, the array will become
    {'h', 'e', 'l', 'l', 'o', '\0'}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education