Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an Octave function called calc_num_vowels.m that takes as input a string of any length. The string can contain spaces. The function must determine the

Write an Octave function called calc_num_vowels.m that takes as input a string of any length. The string can contain spaces. The function must determine the number of vowels in the string and the location of the vowel in the string. The function must return two output parameters, namely the number of vowels and an array with the location of the vowel in the string. The program should perform the following functionality:

(i) Read a string from the command window as shown in example below.

(ii) Get the string length.

(iii) Check each character in the string if the character is a space then continue. If the character is a vowel, then store the location and increment the number of vowels.

(iv) Return the number of vowels and the vowel location array.

(v) The function must test that there is an input argument.

(vi) The function must print an error message if there are less than two input arguments.

(vii) Hint: Use a vector array to store the element number in the string where the vowel occurs see example below where the vowel i is element 3.

Example: You can test your function with the following test string: [num, arr] = calc_num_vowels('This Is A TesT') num = 4 arr = 3 6 9 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Design Operation And Evaluation Of Mobile Communications

Authors: Gavriel Salvendy ,June Wei

1st Edition

3030770249, 978-3030770242

More Books

Students also viewed these Programming questions

Question

Where do I give in to my bad habit?

Answered: 1 week ago

Question

The antitrust laws are based on the:

Answered: 1 week ago