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

printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

877


What is the use of typedef in c?

796


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

2489


What is the difference between memcpy and memmove?

792


What is the difference between %d and %i?

832


What does 3 mean in texting?

835


Explain is it better to bitshift a value than to multiply by 2?

959


Why cant I open a file by its explicit path?

820


Explain how can you restore a redirected standard stream?

798


What does s c mean in text?

840


What is main function in c?

797


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1765


I heard that you have to include stdio.h before calling printf. Why?

827


What are high level languages like C and FORTRAN also known as?

924


can we implement multi-threads in c.

889