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 / jagjit

#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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c called "mother" language?

1231


what type of questions arrive in interview over c programming?

1982


The statement, int(*x[]) () what does in indicate?

1085


Is int a keyword in c?

906


Explain c preprocessor?

1045


Is file a keyword in c?

887


What is the difference between exit() and _exit() function?

992


Explain bitwise shift operators?

1171


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1674


In a byte, what is the maximum decimal number that you can accommodate?

1072


Write a Program to find whether the given number or string is palindrome.

1228


When c language was developed?

1011


I have a varargs function which accepts a float parameter?

997


what is recursion in C

1019


Write a program with dynamically allocation of variable.

1068