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
What is c mainly used for?
What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file
Difference between linking and loading?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
How can I get back to the interactive keyboard if stdin is redirected?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
What is class and object in c?
write a program to copy the string using switch case?
What is the most efficient way to store flag values?
What is variable and explain rules to declare variable in c?
State the difference between realloc and free.
What is the difference between a free-standing and a hosted environment?
How can I do graphics in c?
is it possible to create your own header files?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9