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...

1. Write the function int countchtr(char string[ ], int ch);
which returns the number of times the character ch appears
in the string.
Example, the call countchtr(“She lives in NEWYORK”, ‘e’)
would return 3.

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
int countchtr(char [],char);
void main()
{
char a[20],ch;
int c;
printf("enter the string :");
gets(a);
printf("enter the char. to be :");
scanf("%c",&ch);
c=countchtr(a,ch);
printf("%d",c);
getch();
}
int countchtr(char a[],char ch)
{
int count=0;
for(int i=0;a[i]!='\0';i++)
{
if(a[i]==ch)
count++;
}
return(count);
}



thank u

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain #pragma statements.

1100


What was noalias and what ever happened to it?

1094


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

1115


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

1130


What is data type long in c?

1116


What are loops in c?

1064


regarding pointers concept

2097


Is array a primitive data type in c?

1131


Difference between Function to pointer and pointer to function

1130


What are the types of type qualifiers in c?

1140


How can I handle floating-point exceptions gracefully?

1242


What is the most efficient way to store flag values?

1230


What is the use of ?

1083


How do I get an accurate error status return from system on ms-dos?

1177


What is the right type to use for boolean values in c? Is there a standard type?

1059