write the function int countchtr(char string[],int
ch);which returns the number of timesthe character ch
appears in the string. for example the call countchtr("she
lives in Newyork",'e') would return 3.

Answer Posted / goloap

int countchtr(char *str, char ch)
{
int count=0;
char *itr = str;
while (*itr != '\0')
{
if(*itr == ch)
{
count++
}
itr++;
}
return count;
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c used in embedded systems?

622


what is different between auto and local static? why should we use local static?

651


please explain every phase in the "SDLC" in the dotnet.

2187


Can a void pointer point to a function?

586


If you know then define #pragma?

686






What is variable in c example?

602


What is putchar() function?

644


What is a pointer in c plus plus?

702


What is the difference between a string and an array?

716


What is an lvalue in c?

703


What are the advantage of c language?

562


What is NULL pointer?

684


What are the differences between Structures and Arrays?

618


What is a good way to implement complex numbers in c?

602


What are the rules for the identifier?

683