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

#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


Please Help Members By Posting Answers For Below Questions

What is #line?

1111


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

1308


Explain is it better to bitshift a value than to multiply by 2?

1250


Explain about the functions strcat() and strcmp()?

1095


Tell me what is the purpose of 'register' keyword in c language?

1039


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

2469


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

1598


how to write optimum code to divide a 50 digit number with a 25 digit number??

3301


what are non standard function in c

1969


What is line in c preprocessor?

1101


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1757


What is scope rule in c?

1122


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

6024


Explain how do I determine whether a character is numeric, alphabetic, and so on?

1181


What is floating point constants?

1191