Answers for "how to count string"

4

count in python

it counts the number of elements in the list or in the string(words)
Posted by: Guest on June-06-2020
0

count letter in string

#include<stdio.h>
#include<string.h>

int main() {
    char c;
    char s[100];
    scanf("%c", &c);
    scanf("%s", s);
    int count = 0;
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
        if (s[i] == c) {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}
Posted by: Guest on July-18-2021

Code answers related to "how to count string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language