PDA

View Full Version : CS201 Solution 2nd Assignment Spring 2010 May 4



viki
05-04-2010, 10:04 PM
its for idea make ur self


#include<iostream>
using namespace std;
/*Function*/
int count_repeats(int array2[],int compare_element,int j){
int counter = 0,i;
for(i=j;i<10;i++)
{
if(array2[i]==compare_element)
counter++;
j--;
}
return counter;
}
/*Main Method*/
int main(){
int array1[10],i,j,no_of_repeats;
cout<<"Enter the length of the array you want to campre ... ";/*By assingnment set length to 10 time*/
cin>>j;
for(i=0;i<j;i++){
cout<<"Enter the Elements : ";
cin>>array1[i];
}

for(i=0;i<10;i++){
no_of_repeats = count_repeats(array1,array1[i],i);
if(no_of_repeats > 1){
cout<<"Element "<<array1[i]<<" repeats:"<<no_of_repeats<<" times \n";
}
}
return 0;
system("pause");
}