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
What is wrong in this statement? scanf(ā%dā,whatnumber);
What is sizeof return in c?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
What is formal argument?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is the right type to use for boolean values in c? Is there a standard type?
What standard functions are available to manipulate strings?
Explain what is page thrashing?
Calculate 1*2*3*____*n using recursive function??
what is the difference between class and unio?
Where in memory are my variables stored?
Explain how can you tell whether a program was compiled using c versus c++?
What does stand for?
What are identifiers in c?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }