C++/c++

Advertisement


Question
Hi Sam,

My previous questions were about calulating how many times the first and second number in a sequence of numbers occurs. You told me to read  number 2 times if I wanted to know how many times the second number occurs. What do I do if I wanted to know how many times for example the 10th number in the sequence occurs. What is the easy way instead of reading number ten times which is a rather long winded approach.

Thanks
Dav

Answer
That's the only way to go. Remember that you can use a for loop to reach the 10th number, or you can first read numbers in an array, and then process it. This way, even if the 10th number also occures in the second position, it will be considered, by comparing all numbers against the 10th number.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Sam

Expertise

You may ask me about simple to complicated C/C++ programming methods/style and most like questions about network programming in C++.

Experience

I'm a professional programer in C++ and network/internet programming.

©2016 About.com. All rights reserved.