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 / vignesh1988i

a small change..............

#include<stdio.h>
#include<conio.h>
int string(char *,char);
void main()
{
char str[100],ch;
int c;
printf("enter the string :");
gets(str);
printf("enter the character to be searched :");
scanf("5c",&ch);
c=string(&str[0],ch);
printf("the character %c occurs for %d times ",ch,c);
getch();
}
int string(char *a,char ch)
{
int count=0;
for(int j=0;*a!='\0';j++)
{
if(*a==ch)
{
count++;
*a++;
}
}
return count;
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

713


What is sizeof return in c?

603


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

664


What is formal argument?

633


can anyone suggest some site name..where i can get some good data structure puzzles???

1635






What is the right type to use for boolean values in c? Is there a standard type?

549


What standard functions are available to manipulate strings?

552


Explain what is page thrashing?

599


Calculate 1*2*3*____*n using recursive function??

1503


what is the difference between class and unio?

1847


Where in memory are my variables stored?

618


Explain how can you tell whether a program was compiled using c versus c++?

565


What does stand for?

582


What are identifiers in c?

618


#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }

653