Find maximum occurring character in a sentence

C program to find maximum occurring character in a sentence.

Program

#include<stdio.h>
#include<conio.h>
#define MAX 50

void main()
{
	char str[MAX];
    int i, freq[256] = {0};
    int max;

    printf("Enter the string\t:");
    gets(str);

    i = 0;
    while(str[i] != '\0')
    {
        freq[str[i]]++;
        i++;
    }

    max = 0;
    for(i=0;i<256;i++)
    {
        if(freq[i] > max)
        {
            max = freq[i];
        }
    }

    for(i=0;i<256;i++)
    {
        if(freq[i] == max)
        {
            printf("\nMaximum occuring element is'%c'",i);
        }
    }

    getch();
}

Output

Enter the string        :welcome to coursecrux.com

Maximum occuring element is'c'
Maximum occuring element is'o'