Question 1 a) Use pseudocode to describe an algorithm that counts the number of letters, digits and special characters in a string. Anything between 'a' or 'A' and 'z' or 'Z' is considered a letter, anything between 0 and 9 is considered a digit, while anything else is considered a special character. Input: a string s read from the keyboard, for example s = '3 beautiful days.' Output: letter count / = 13, digit count d = 1, special character count c = 3 For solving this task, consider the string to be an array of characters and do not use any predefined functions that would make this task trivial. b) Show an implementation of the algorithm designed in the language of your choice. You will not be penalised for small syntactical errors. c) Implement an algorithm in the language of choice that counts the occurrence of a digit in a number recursively. Input: a number n read from the keyboard, for example n = 30563323 a digit d the occurrences of which should be counted, for example d = 3 Output: a number c = 4 (i.e., how many of digit d there are in n). For solving this task, consider the string to be an array of characters. You can use any predefined functions in the language of your choice, however their name and number/location of arguments must be accurate.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
Question
Question 1
a) Use pseudocode to describe an algorithm that counts the number of letters, digits and
special characters in a string. Anything between 'a' or 'A' and 'z' or 'Z' is considered a
letter, anything between 0 and 9 is considered a digit, while anything else is considered a
special character.
Input: a string s read from the keyboard, for example s = '3 beautiful days.'
Output: letter count / = 13, digit count d = 1, special character count c = 3
For solving this task, consider the string to be an array of characters and do not use any
predefined functions that would make this task trivial.
b) Show an implementation of the algorithm designed in the language of your choice. You
will not be penalised for small syntactical errors.
c) Implement an algorithm in the language of choice that counts the occurrence of a digit in a
number recursively.
Input:
a number n read from the keyboard, for example n = 30563323
a digit d the occurrences of which should be counted, for example d = 3
Output: a number c = 4 (i.e., how many of digit d there are in n).
For solving this task, consider the string to be an array of characters. You can use any
predefined functions in the language of your choice, however their name and
number/location of arguments must be accurate.
Transcribed Image Text:Question 1 a) Use pseudocode to describe an algorithm that counts the number of letters, digits and special characters in a string. Anything between 'a' or 'A' and 'z' or 'Z' is considered a letter, anything between 0 and 9 is considered a digit, while anything else is considered a special character. Input: a string s read from the keyboard, for example s = '3 beautiful days.' Output: letter count / = 13, digit count d = 1, special character count c = 3 For solving this task, consider the string to be an array of characters and do not use any predefined functions that would make this task trivial. b) Show an implementation of the algorithm designed in the language of your choice. You will not be penalised for small syntactical errors. c) Implement an algorithm in the language of choice that counts the occurrence of a digit in a number recursively. Input: a number n read from the keyboard, for example n = 30563323 a digit d the occurrences of which should be counted, for example d = 3 Output: a number c = 4 (i.e., how many of digit d there are in n). For solving this task, consider the string to be an array of characters. You can use any predefined functions in the language of your choice, however their name and number/location of arguments must be accurate.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr