Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Finding repeated integers and their frequency.

0 votes
asked Aug 28, 2018 by Novice (240 points)
edited Aug 29, 2018 by Novice
Hello, I am a Novice.

I wanted to find the unique integers, repeated integers, and their frequency. Here I'm using 10 integers. This is my code for now. Can you explain to me where I am wrong and how should I fix it? Also How show to display unique integers.

#include <stdio.h>

int main()


int i , j, repeated , number[10]={1,2,2,1,3,5,3,7,9,1};

      printf("Enter 10 integers :");

for(i=0; i<10; i++)


repeated = 0;

    for(j=0; j<10; j++)







      printf("\n%d was repeated %d times\n",number[i],repeated);


return 0;


2 Answers

0 votes
answered Aug 28, 2018 by kanth (200 points)
you have to print "repeated" in the last print statement instead of c which is undecleared
commented Aug 29, 2018 by Novice (240 points)
that really wasn't the problem. I was changing the variable from 'c' to 'repeated' that is when I missed it. But it was when I copied it here. Thanks for pointing it out though.
0 votes
answered Sep 4, 2018 by anonymous

ok, I don't know what exactly you want the output to look like, but I can see that

in you'r code there's a needless repetition, for example, you count that number '1' is repeated 3 times

 3 different times!, so what I suggest to you to indicate the a certain number is checked, for Example, when you checked

for number 1 remove it from the array!, what do I mean by remove, if you have for example a postiive array you can put '-1'

to mark that an element is removed from here and skip, so you don't count the repition of number '1' many times.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.