C Programming Code Examples C > Strings Code Examples Check whether a given Character is present in a String, Find Frequency & Position of Occurrence Check whether a given Character is present in a String, Find Frequency & Position of Occurrence #include <stdio.h> #include <string.h> int main() { char a, word[44]; int j, freq = 0, flag = 0; printf("Enter character: "); scanf("%c", &a); printf("Now enter the word: "); scanf("%s", word); printf("Positions of '%c' in %s are: ", a, word); for (j = 0; j < strlen(word); j++) { if (word[j] == a) { flag = 1; printf("%d ", j + 1); freq++; } } if (flag) { printf("\nCharacter '%c' occured for %d times.\n", a, freq); } else { printf("None\n"); } return 0; }