hi every1 i m trying to write a simple code to count the no. of times a no. repeats in an array.....so plzzz try some logics!! without using any builtin function
hi every1 i m trying to write a simple code to count the no. of times a no. repeats in an array.....so plzzz try some logics!! without using any builtin function
So, what is your plan and what have you done so far?Originally Posted by aaditg
In a way, there are no built-in functions in C++.Originally Posted by aaditg
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I hope this source code will help u.
Code:#include <iostream> using namespace std; int main() { int array[14]={1,1,3,4,2,64,2,3,1,3,4,53,5,6},num,i,count=0; cout<<"Enter the number you want to count: "; cin>>num; for(i=0;i<=13;++i) { if(array[i]==num) ++count; //Increase the count, if number matches array } cout<<"The number of repition of "<<num<<" is "<<count<<" times"; return 0; }
programiz: please do not give code handouts prematurely.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"