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
Printable View
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?Quote:
Originally Posted by aaditg
In a way, there are no built-in functions in C++.Quote:
Originally Posted by aaditg
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.