A simple Code To count frequency of numbers in an array..

This is a discussion on A simple Code To count frequency of numbers in an array.. within the C++ Programming forums, part of the General Programming Boards category; hi every1 i m trying to write a simple code to count the no. of times a no. repeats in ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    1

    A simple Code To count frequency of numbers in an array..

    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

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,954
    Quote Originally Posted by aaditg
    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!!
    So, what is your plan and what have you done so far?

    Quote Originally Posted by aaditg
    without using any builtin function
    In a way, there are no built-in functions in C++.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2012
    Location
    Kathmandu
    Posts
    4
    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;
    }

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,954
    programiz: please do not give code handouts prematurely.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,260
    Quote Originally Posted by programiz View Post
    "The number of repition of "
    I think you need a bit more repetition there.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch Case for Counting Frequency of numbers
    By sjmp in forum C Programming
    Replies: 11
    Last Post: 07-30-2012, 12:35 PM
  2. count and print the frequency of each ASCII character
    By s_jsstevens in forum C Programming
    Replies: 3
    Last Post: 02-07-2011, 08:33 PM
  3. Replies: 9
    Last Post: 03-13-2010, 02:40 AM
  4. very simple code to match letters to numbers
    By kop442000 in forum C Programming
    Replies: 14
    Last Post: 07-24-2009, 05:16 PM
  5. I'm trying to count the frequency of the phrase "ing"
    By thefreeman1159 in forum C Programming
    Replies: 14
    Last Post: 09-23-2008, 11:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21