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 / vadivel t

#include<stdio.h>
#include<conio.h>

int main()
{
char ptr[100]= "She lives in NEWYORK";
char ch;
printf("ENTER THE CHARACTER:\n");
scanf("%c", &ch);
printf("CHAR %c EXIST %d TIME(S)\n",ch, countchtr(ptr, ch));
getch();
}

int countchtr(char *ptr, char ch)
{
int count = 0;
char ch1;
if(ch >= 97 && ch <= 122)
{
ch1 = ch - 32;
}
else if(ch >= 65 && ch <= 96)
{
ch1 = ch + 32;
}
while(*ptr != '\0')
{ if((*ptr == ch) || (*ptr == ch1))
{
count++;
}
ptr++;
}
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

Explain what is the heap?

1016


Explain the properties of union. What is the size of a union variable

1133


What is typedef struct in c?

1003


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

3092


What is the symbol indicated the c-preprocessor?

1168


What do you mean by dynamic memory allocation in c?

1053


List some basic data types in c?

976


How many loops are there in c?

1049


Tell us two differences between new () and malloc ()?

1119


How do you sort filenames in a directory?

1128


Compare and contrast compilers from interpreters.

1078


What is main () in c?

1015


Is there a way to compare two structure variables?

1061


What does emoji p mean?

1047


Is there any possibility to create customized header file with c programming language?

1009