#include #include /* This program is made available under the terms of the GNU Copyleft */ int main(void) { char symbols[20]; double sym; double bits; /*get the nums*/ printf("How many symbols are available in this system ?\n"); //gets(symbols); if (fgets(symbols,20,stdin) == NULL) { exit(1);} /*conv to values*/ sym=atol(symbols); bits= log10(sym) / (log10(2)); /*shannon's law is expressed in terms of log2(x) hence fiddly conversion*/ printf("This is a radix=%g system with %g bits per symbol.\n\n", sym, bits); return 0; }