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
#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 ? | 4 Yes | 2 No |
Post New Answer View All Answers
What is the size of empty structure in c?
What happens if you free a pointer twice?
Explain the concept and use of type void.
Explain how do you view the path?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
I need testPalindrome and removeSpace
#include
State two uses of pointers in C?
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
What does char * * argv mean in c?
How do I swap bytes?
Give the rules for variable declaration?
can we have joblib in a proc ?
please explain every phase in the "SDLC" in the dotnet.
Does free set pointer to null?