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
Differentiate between a structure and a union.
What is fflush() function?
What is the difference between exit() and _exit() function?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
What are pointers?
What is static identifier?
Why main function is special give two reasons?
List some basic data types in c?
will u please send me the placement papers to my mail???????????????????
Is there sort function in c?
What is the purpose of void pointer?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
Should I learn data structures in c or python?
explain how do you use macro?
is it possible to create your own header files?