Frequency of a character in a sting

C program to find the frequency of a character in a string.

Program

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

void main()
{
	char str[MAX];
    int i, freq;
    char ch;

    printf("Enter the string\t:");
    gets(str);
    printf("Enter the character whose frequency is to be found\t:");
    scanf("%c",&ch);

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

    printf("\nFrequency of %c = %d",ch, freq);

    getch();
}

Output

Enter the string        :welcome to coursecrux.com
Enter the character whose frequency is to be found      :e

Frequency of e = 3