Ask Question
1 March, 02:24

Assume s is a string of lower case characters.

Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print

Number of times bob occurs is: 2

+1
Answers (1)
  1. 1 March, 06:06
    0
    Here's an attempt in C:

    #include

    int CountBob (const char * s)

    {

    int n = 0;

    while (s = strstr (s, "bob")) {

    n++;

    s++;

    }

    return n;

    }

    int main ()

    {

    char * s = "azcbobobegghakl";

    int n = CountBob (s);

    printf ("Number of times bob occurs is: %d", n);

    getchar ();

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume s is a string of lower case characters. Write a program that prints the number of times the string 'bob' occurs in s. For example, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers