Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the modifiers available in c programming language?

1224


What are different types of operators?

1046


What is omp_num_threads?

1090


What are the different types of errors?

1142


What is a stream in c programming?

1156


What is zero based addressing?

1177


What language is lisp written in?

1271


What are the advantages and disadvantages of a heap?

1216


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1955


What is the difference between mpi and openmp?

1302


Write a program to print ASCII code for a given digit.

1096


How can a program be made to print the line number where an error occurs?

1089


What does s c mean in text?

1098


How does placing some code lines between the comment symbol help in debugging the code?

1006


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1777