Hi, everyone.
So in this video, we are going to solve this question, count the occurences of an element.
So, for example, if this is already so the elements are, let's say, five, five, six, five and
six, so the value of X is five.
So how many times five is appearing?
Seven times second time and third time.
So five is better than the average three times.
So output should be three.
Similarly, if the value of existing so if the value of X is basically six, then six is present one
time and second time.
So output should be two.
Similarly, if the value of X system so ten is not present inside the three, so output should be zero.
So we can solve this question easily with the help of follow up.
So what we will do.
You're simply outraged over the ad, and whenever you see the value, let's take a variable answer.
Whenever you see the value X, you will answer placeless and you will move ahead.
Similarly, you will see the value again.
You will you will again do answer Lespinasse and you will stop when you will reach the end.
So we just need to maintain a variable answer.
And whenever we see the X value, I will do answer.
So let us write the code.
So I'm not returning anything.
I will take a variable, so one thing.
We need to solve this question with the help of equation, and that is obvious there a functional void
void, a function I will take areas in, but I will take a number of elements I for a rating of Arrietty
X the value, and we will take this outside variable, we will take this outside variable and we will
take this variable by reference.
Initially, the value of this answer will be zero.
So then we will write the code.
So whenever we find the value I will do on C++ and initially the value of funds will be zero because
I will call the function from me and I will pass the answer zero.
And since I am printing the answer inside me, so I will print my answer inside mean.
And that's why I need to pass the answer variable by reference.
So.
The name of the function is count.
Count occurences or let's name it, count only, we will take it as input.
We will take how many elements are there and we will take X, we will take the next time for our trading
order and we will take on some variable Bio-Reference because we are going to paint the answer inside
mean.
So how I will call this function.
So initially, let's create another variable here and say zero, I will call the function count, I
will pass any I will pass a number of elements, which is six data, which I want to search for.
I want to search for five.
How many times five is appearing, how many times five is appearing in my data, I will start iterating
from zero and answer variable.
So this function will update the value of a variable and now we can print the answer here.
Simple and let's come out.
So this is count function.
So here we can just copy this code.
So if I become too close to him, then I will stop and return, if I is equal to X, then I do not need
to print anything.
I will just do answer placeless, so I will do answer placeless and I need to call the government function.
And I will give answer also, and that is how I think our function will work.
So let's test for five.
So five is present one, two and three times.
So five is three times.
So arbitrary, arbitrary.
So I didn't say semicolon.
So output should be three and tasty, right, output, so let's say I want to search for six, six percent
two times.
So this exists two times now let's test for seven, seven is present only one time.
So seven is one and then is not pleasant inside, there is no output should be zero.
So I put this zero.
So our function is working, so this is it from this video, I will see you in the next one.