Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Which control loop is recommended if you have to execute set of statements for fixed number of times?

1351


What are the standard predefined macros?

1148


What is the purpose of the preprocessor directive error?

1276


Do string constants represent numerical values?

1407


Explain what is the purpose of "extern" keyword in a function declaration?

1075


Should I learn c before c++?

1237


What is the meaning of && in c?

1024


how is the examination pattern?

2025


How to delete a node from linked list w/o using collectons?

2784


How do I determine whether a character is numeric, alphabetic, and so on?

1140


Describe explain how arrays can be passed to a user defined function

1109


5 Write an Algorithm to find the maximum and minimum items in a set of ā€˜n’ element.

2117


What is the difference between array and linked list in c?

1160


What is the time and space complexities of merge sort and when is it preferred over quick sort?

1085


Can you tell me how to check whether a linked list is circular?

1430