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 a double c?
how to introdu5ce my self in serco
What is difference between structure and union?
What are the 4 types of organizational structures?
Explain how do you declare an array that will hold more than 64kb of data?
Is javascript based on c?
Is calloc better than malloc?
Who developed c language?
What does char * * argv mean in c?
Differentiate between functions getch() and getche().
Explain how do you print only part of a string?
Without Computer networks, Computers will be half the use. Comment.
Can you write a programmer for FACTORIAL using recursion?
Explain about C function prototype?
Why c is a mother language?