Find minimum occurring character in a sentence

C program to find minimum 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 min;

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

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

    for(i=0;i<256;i++)
    {
        if(freq[i] != 0)
        {
            min = freq[i];
            break;
        }
    }
    for(i=0;i<256;i++)
    {
        if(freq[i]<min && freq[i]!=0)
        {
            min = freq[i];
        }
    }

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

    getch();
}

Output

Enter the string        :welcome to coursecrux.com

Minimum occuring element is'.'
Minimum occuring element is'l'
Minimum occuring element is's'
Minimum occuring element is't'
Minimum occuring element is'w'
Minimum occuring element is'x'