Embed presentation
Download to read offline


![Logic
• Given array for example:
• arr[]={1,2,3,2,3,2,2}
• Element to be find is 2 (No.of times repeated)
• How to find the repeated element present in an
array
• Soln:Using for loop:
• for (i=0;i<n;i++)
• if(a[i]==ele)(main logic)
• counter++;](https://image.slidesharecdn.com/frequencycount-200912121451/85/Frequency-count-of-the-Element-in-an-array-3-320.jpg)

![• #include<iostream.h>
• #include<conio.h>
• void main()
• {
• int a[100],ele,n,i,freq;
• clrscr();
• cout<<"Enter the size of array"<<endl;
• cin>>n;
• cout<<"Enter the elements of array"<<endl;
• for(i=0;i<n;i++)
• {
• cin>>a[i];
• }
• cout<<"Enter the element to be counted"<<endl;
• cin>>ele;
• freq=0;
• for(i=0;i<n;i++)
• {
• if(a[i]==ele)
• {
• freq=freq+1;
• }
• }
• cout<<"Frequency of "<<ele<<" is "<<freq;
• getch();
• }](https://image.slidesharecdn.com/frequencycount-200912121451/85/Frequency-count-of-the-Element-in-an-array-5-320.jpg)


The document outlines a C++ program designed to count the frequency of a specific element in an array. It includes steps for array declaration, inputting values, and using a for loop to determine how many times the specified element appears. A sample code snippet is presented to demonstrate the implementation of the logic.


![Logic
• Given array for example:
• arr[]={1,2,3,2,3,2,2}
• Element to be find is 2 (No.of times repeated)
• How to find the repeated element present in an
array
• Soln:Using for loop:
• for (i=0;i<n;i++)
• if(a[i]==ele)(main logic)
• counter++;](https://image.slidesharecdn.com/frequencycount-200912121451/85/Frequency-count-of-the-Element-in-an-array-3-320.jpg)

![• #include<iostream.h>
• #include<conio.h>
• void main()
• {
• int a[100],ele,n,i,freq;
• clrscr();
• cout<<"Enter the size of array"<<endl;
• cin>>n;
• cout<<"Enter the elements of array"<<endl;
• for(i=0;i<n;i++)
• {
• cin>>a[i];
• }
• cout<<"Enter the element to be counted"<<endl;
• cin>>ele;
• freq=0;
• for(i=0;i<n;i++)
• {
• if(a[i]==ele)
• {
• freq=freq+1;
• }
• }
• cout<<"Frequency of "<<ele<<" is "<<freq;
• getch();
• }](https://image.slidesharecdn.com/frequencycount-200912121451/85/Frequency-count-of-the-Element-in-an-array-5-320.jpg)
