ibrahim_065

6.Write aprogram to find how many 0’s ,1’s, ..., 10’s exist in the array x.

Aug 13th, 2020 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. /*Suppose  we  read n random integer  numbers  into  an  array  declared  by int  x[100].
  2. We know  that  all  the integer  numbers  arebetween  0  and  10.
  3. Write  aprogram  to  find  how many 0’s ,1’s, ..., 10’s exist in the array x.*/
  4. #include<stdio.h>
  5. int main()
  6. {
  7.     int n, x[100], y[11] = {0};
  8.     scanf("%d", &n);
  9.     for (int i = 0; i < n; ++i)
  10.     {
  11.         scanf("%d", &x[i]);
  12.         y[x[i]] += 1;
  13.     }
  14.     for (int i = 0; i <= 10; ++i)
  15.     {
  16.         printf("Frequency of %d\'s: %d\n", i, y[i]);
  17.     }
  18.     return 0;
  19. }
Add Comment
Please, Sign In to add comment