Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Repetitions in array

haseebkhiljihaseebkhilji Member Posts: 1
After getting input, How the method finds the elements with repetition and number of times each element is repeated with in the array of integer (int a[10])?

Comments

  • SkyterrorSkyterror Member Posts: 16
    You mean like this?

    Searching the element which is same with input

    int i=0;
    while((i<10) && (a[i] != input)) i++;

    if(i == 10)
    /*
    ADD YOUR CODE HERE:

    it means that our loop never found input in array. This is because all the condition of loop is true (remember logic table of and / &&)

    */
    else
    /*
    ADD YOUR CODE HERE:

    it means that our loop is break in middle of operation so the value of i is never achieve 10. This is done because there are at least 1 condition which get false as the loop operate.

    */
Sign In or Register to comment.