Sign Up

Talk Programming , Career, Mental Health, Talk Personal Finance ❤️‍ Post a query and receive responses ✅

Have an account? Sign In


Have an account? Sign In Now

Sign In

Post a query and receive responses. Ask anything, Ask Mitra ❤️‍

Sign Up Here


Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.


Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Ask Mitra

Ask Mitra Logo Ask Mitra Logo

Ask Mitra Navigation

  • Home
  • About Us
  • Find Jobs
  • Blogs
    • Add New Blog !
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Ask a Question
  • Home
  • All Categories
  • Find Jobs
  • Points and Swags
    • Badges and Points
    • Ask Mitra Swags
  • Blog
    • Add New Blog !
  • FAQs
  • Community Members 💓
  • About Us
  • Contact Us
Home| Questions|Q 74436
Next
In Process
BidhanN
BidhanN
Asked: August 13, 20222022-08-13T14:21:02+05:45 2022-08-13T14:21:02+05:45In: —C & C#

WAP to find the frequency of numbers present in a list. Solve in C and C++

eg: 1,2,2,3,10,90,88,47,58,83
Output: 0-10=5

11-20=0

c++
  • 2
  • 3 3 Answers
  • 86 Views
  • 0 Followers
  • 0
Share
  • Facebook

    Related Questions

    • What is wrong here??
    • Need to find if the array contains same number certain times consecutively.
    • I have to submit my C project due by tomorrow but graphics.h isn't working,why?
    • WAP To find any term of fibonacci series using recursion
    • WAP to convert AD Data to BC data (using structure) using C and C++

    You must login to add an answer.


    Forgot Password?

    Need An Account, Sign Up Here

    3 Answers

    • Voted
    • Oldest
    • Recent
    • Random
    1. Yujan Ranjitkar Explainer Hey you! Yes you, Let’s build something awesome together.
      2022-08-13T15:12:02+05:45Added an answer on August 13, 2022 at 3:12 pm
      This answer was edited.

      Using C

      
      
      
      
      #include <stdio.h>
      
      int main()
      {
      //Initialize array
      int arr[] = {1, 2, 2, 3, 10, 90, 88, 47, 58, 83};
      int i, j;
      //Calculate length of array arr
      int length = sizeof(arr)/sizeof(arr[0]);
      //Array fr will store frequencies of element
      int fr[length];
      int visited = -1;
      for(i = 0; i < length; i++){
      int count = 1;
      for(j = i+1; j < length; j++){
      if(arr[i] == arr[j]){
      count++;
      //To avoid counting same element again
      fr[j] = visited;
      }
      }
      if(fr[i] != visited)
      fr[i] = count;
      }
      //Displays the frequency of each element present in array
      printf("---------------------n");
      printf(" Element | Frequencyn");
      printf("---------------------n");
      for(i = 0; i < length; i++){
      if(fr[i] != visited){
      printf(" %d", arr[i]);
      printf(" | ");
      printf(" %dn", fr[i]);
      }
      }
      printf("---------------------n");
      return 0;
      }
      
      
      • 1
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. stutiupreti Suti
      2022-08-13T16:44:46+05:45Added an answer on August 13, 2022 at 4:44 pm
      This answer was edited.

      Using c++

      #include <bits/stdc++.h>
      using namespace std;
      
      // Main function to run the program
      int main() 
      { 
          int arr[] = {10, 30, 10, 20, 10, 20, 30, 10}; 
          int n = sizeof(arr)/sizeof(arr[0]); 
      
          int visited[n];
      
          for(int i=0; i<n; i++){
      
              if(visited[i]!=1){
                 int count = 1;
                 for(int j=i+1; j<n; j++){
                    if(arr[i]==arr[j]){
                       count++;
                       visited[j]=1;
                    }
                  }
      
                  cout<<arr[i]<<" occurs at "<<count<<" times "<<endl;
               }
           }
      
          return 0; 
      }
      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. stutiupreti Suti
      2022-08-13T16:48:55+05:45Added an answer on August 13, 2022 at 4:48 pm

      Using C

      #include <stdio.h>
      
      void main()
      {
          int arr1[100], fr1[100];
          int n, i, j, ctr;
      
      
             printf("nnCount frequency of each element of an array:n");
             printf("------------------------------------------------n");    
      
             printf("Input the number of elements to be stored in the array :");
             scanf("%d",&n);
      
             printf("Input %d elements in the array :n",n);
             for(i=0;i<n;i++)
                  {
                printf("element - %d : ",i);
                scanf("%d",&arr1[i]);
                fr1[i] = -1;
              }
          for(i=0; i<n; i++)
          {
              ctr = 1;
              for(j=i+1; j<n; j++)
              {
                  if(arr1[i]==arr1[j])
                  {
                      ctr++;
                      fr1[j] = 0;
                  }
              }
      
              if(fr1[i]!=0)
              {
                  fr1[i] = ctr;
              }
          }
          printf("nThe frequency of all elements of array : n");
          for(i=0; i<n; i++)
          {
              if(fr1[i]!=0)
              {
                  printf("%d occurs %d timesn", arr1[i], fr1[i]);
              }
          }
      }
      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Sidebar

    Ask A Question

    Your Favourite Topics

    • Announcements
    • Blockchain
    • Books

        • —Non Tech Books
        • —technical books
    • Business and Entrepreneurship
    • Careers
    • College
    • Content and Blog
    • CyberSecurity
    • Design and Arts
    • Devices and Gadgets
    • Digital Marketing
    • Entertainment

        • —Movies-Series-TV
        • —Music
        • —Sports
    • Events
    • For Admins only.
    • Health

        • —Fitness
    • Money

        • —Personal Finance
        • —Stock Market
    • Operating System

        • —linux
        • —windows
    • Other
    • Paid Internship
    • Programming

        • —AI/ML
        • —APIs
        • —C & C#
        • —Django
        • —Flutter
        • —Go
        • —HTML&CSS
        • —Java
        • —JavaScript
        • —Mobile Apps Development
        • —Node Js
        • —NoSQL
        • —Php
        • —Python
        • —React JS
        • —SQL

    Stats

    • Questions 1k
    • Answers 10k
    • Best Answers 394
    • Users 2k

    Top 6 Members This Month

    Vicky

    Vicky

    • 0 Questions
    • 78 Points
    Sensei
    puppet

    puppet

    • 0 Questions
    • 23 Points
    Beginner
    wtfixair

    wtfixair

    • 0 Questions
    • 22 Points
    Beginner
    Dhanmaya

    Dhanmaya

    • 0 Questions
    • 20 Points
    Beginner
    Riyesh

    Riyesh

    • 0 Questions
    • 20 Points
    Beginner
    pranitkarki

    pranitkarki

    • 0 Questions
    • 20 Points
    Beginner

    Trending Tags

    blockchain c++ career coding College cybersecurity Django Flutter help html javascript laptop laravel linux poll Programming python question react web web development wordpress
    • Popular
    • Answers
    • Rounak Agrawal

      Ask Mitra Udemy Courses Giveaway

      • 76 Answers
    • Subedi Bibek

      The Complete JavaScript Course 2022: From Zero to Expert! Udemy ...

      • 73 Answers
    • Subedi Bibek

      Mega Giveaway at askmitra.com 🔥

      • 69 Answers
    • Sandeep Poudel
      Sandeep Poudel added an answer SOLVED: It was due to unfinished SSL certificate installation January 27, 2023 at 7:11 pm
    • Aashutosh_k
      Aashutosh_k added an answer Software piracy protection system Fingerprint voting system Stock price prediction… January 26, 2023 at 7:37 pm
    • Sangam AKA Ronnie
      Sangam AKA Ronnie added an answer Did you miss my video. https://youtu.be/Wo0NxEivd7A watch at end to… January 24, 2023 at 9:13 pm

    Related Questions

    • Can your please suggest best resources for DSA in C++?

      • 2 Answers
    • What is wrong here??

      • 1 Answer
    • ASP dot net web api

      • 0 Answers
    • c language

      • 6 Answers
    • Idk what is the reason can anyone help with it

      • 4 Answers

    Explore

    • Home
    • Trending Category
      • Programming
      • Web Development
      • —Mobile Apps Development
      • —Stock Market
      • Business and Entrepreneurship
      • Blockchain
      • College
      • —Personal Finance
      • —HTML&CSS
      • —JavaScript
      • —Python
      • —React JS
      • —Node Js
      • —C & C#
      • Content and Blog
      • Careers
    • All Categories
      • Go to All Categories
      • Health
      • —Go
      • —Flutter
      • Digital Marketing
      • —APIs
      • Devices and Gadgets
    • Find Job and Internships
    • Points and Swags
      • Badges and Points
      • Ask Mitra Swags
    • All Blogs
      • Add New Blog !
    • FAQs
    • Community Members 💓
    • Questions
      • Un Answered
      • New Questions
      • Most Seen Questions
      • Most Answered
      • Trending Questions
    • Tags

    Footer

    Ask Mitra

    Ask Mitra

    Ask Mitra is a social question and answer engine that will assist you in forming a community and connecting with others. Talk about programming, your career, your mental health, and your personal finances. ❤️‍ Post a query and receive responses ✅

    Quick Navigation

    • Ask a Question
    • Home
    • All Categories
    • Find Jobs
    • Points and Swags
      • Badges and Points
      • Ask Mitra Swags
    • Blog
      • Add New Blog !
    • FAQs
    • Community Members 💓
    • About Us
    • Contact Us

    Legal Stuff

    • Terms of use and policy