Advertisement
lnsee96

1-14

Aug 6th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Write a program to print a histogram of the frequencies of different characters in its input*/
  2. //Horizontal Version
  3.  
  4. #include<stdio.h>
  5. //characters in ASCII code from number 32 to 127
  6. main()
  7. {
  8.     char characters [95];
  9.     int c,i,l,counter;
  10.     for(i=0;i<=95;i++)
  11.     {
  12.         characters[i]=0;
  13.     }
  14.     printf("Insert your input:\n");
  15.     while((c=getchar())!=EOF)
  16.     {
  17.         characters[c-37]++;
  18.     }
  19.     for (i=0;i<=95;i++)
  20.     {
  21.         printf("|%c|",i+37);
  22.         for(counter=1;counter<=characters[i];++counter)
  23.         {
  24.             printf("*");
  25.         }
  26.  
  27.         printf("\n");
  28.     }
  29.     scanf("%d,l");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement