Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function that, given any input integer vector , and any integer scalar , returns the number of times the scalar value appears in

Write a function that, given any input integer vector, and any integer scalar, returns the number of times the scalar value appears in the vector.

You must use looping and branching (examining each element) to implement this function.

Again, the input arguments are a 1D array (i.e., a vector) and a scalar (i.e., a single value)

For example, given the inputs [ 1 ; -1 ; 1 ] and 1, the result is 2

For example, given the inputs [ -3,4,3,-3,-4 ; -3,-2,-3,0,-3 ] and -3, the result is 5 For example, given the inputs [ 0,1,2 ] and 2, the result is 1 For example, given the inputs [ 1,3,5 ] and 7, the result is 0

Note that the result is returned by the function, not printed by the function.

Remember that the input calling argument's values come from outside of the function and are not to be set within the function.

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions