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
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What are the standard predefined macros?
What is the purpose of the preprocessor directive error?
Do string constants represent numerical values?
Explain what is the purpose of "extern" keyword in a function declaration?
Should I learn c before c++?
What is the meaning of && in c?
how is the examination pattern?
How to delete a node from linked list w/o using collectons?
How do I determine whether a character is numeric, alphabetic, and so on?
Describe explain how arrays can be passed to a user defined function
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
What is the difference between array and linked list in c?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Can you tell me how to check whether a linked list is circular?