Hi vsriharsha,
Nice try but your code is not save:
Try to use fgets in stead of gets. This is more save because you can specify the lenght of your input buffer. Second, when you use gets (or fgets) you need to allocate space for your input buffer.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
{
/* ASCII: A-Z = 65-90, a-z = 97-122 */
char line[1024];
char *ptr;
int array[26];
int i;
memset(array, 0, 26 * sizeof(int));
printf("Enter string\n");
fgets(line, 1024, stdin);
for(ptr = line; *ptr; ptr++)
if(isalpha(*ptr))
array[tolower(*ptr)-97] += 1;
for(i = 0; i < 26; i++)
printf("%c -> %d time%s\n", i+97, array[i], array[i] == 1 ? "" : "s");
return 0;
}