fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int arr[11] = {8 , 3 , 5 , 2 , 3 , 1 , 6 , 5 , 7 , 4 , 3};
  7. int n=11;
  8.  
  9. int frequency[100] = {0}; // here we use the frequency array of size 100
  10.  
  11. for(int i=0; i<n; i++)
  12. {
  13. frequency[arr[i]] = frequency[arr[i]] + 1;
  14. }
  15.  
  16. // 2
  17. int q;
  18. cout<<"Enter No of Queries "<<endl;
  19. cin>>q;
  20.  
  21. for(int i=0; i<q; i++)
  22. {
  23. // 5 6
  24. int x;
  25. cout<<"Enter the No. to find frequency:"<<endl;
  26. cin>>x;
  27.  
  28. cout<<"frequency of: "<<x<<"="<<frequency[x]<<endl; // 5 = 2 , 6 = 1
  29. }
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Enter No of Queries