Answers for "print an integer representing the count of specific character"

C
0

c program to the count the number of times each character appears

#include <stdio.h>
int main() {
    char str[1000], ch;
    int count = 0;

    printf("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    printf("Enter a character to find its frequency: ");
    scanf("%c", &ch);

    for (int i = 0; str[i] != '\0'; ++i) {
        if (ch == str[i])
            ++count;
    }

    printf("Frequency of %c = %d", ch, count);
    return 0;
}
Posted by: Guest on July-06-2020
0

print an integer representing the count of specific character

input haveagoodday
Posted by: Guest on July-19-2021
0

print an integer representing the count of specific character

jeeva is a
Posted by: Guest on September-25-2021

Code answers related to "print an integer representing the count of specific character"

Code answers related to "C"

Browse Popular Code Answers by Language