C Tutorial
#include<stdio.h> #define MAX 10 #define COUNTER 5 void main() { float val[MAX]; int i, low, high; static int range[COUNTER] = {0, 0, 0, 0, 0}; /* Reading and Counting */ printf("Enter inputs from 0 to 49\n"); for(i=0;i<MAX;i++) { scanf("%f", &val[i]); ++range[(int)(val[i]/10)]; } /* Printing Frequency*/ printf("\nRange Freuency\n"); for(i=0;i<COUNTER;i++) { low = i*10; high = low + 9; printf(" %3d to %3d %3d\n", low, high, range[i]); } }Output:
cc frequency-counting.c $ ./a.out Enter inputs from 0 to 49 21 23 45 11 9 8 28 14 41 32 Range Freuency 0 to 9 2 10 to 19 2 20 to 29 3 30 to 39 1 40 to 49 2
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page