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 %g in c?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What is function pointer c?
how to find binary of number?
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
List the difference between a "copy constructor" and a "assignment operator"?
Why do some versions of toupper act strangely if given an upper-case letter?
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
What is the significance of c program algorithms?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
What is the difference between formatted&unformatted i/o functions?
What are the types of assignment statements?
Describe static function with its usage?
What are high level languages like C and FORTRAN also known as?