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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is .obj file in c?

639


How can I rethow can I return a sequence of random numbers which dont repeat at all?

695


Is stack a keyword in c?

626


Explain what is the stack?

625


What are runtime error?

615






Why main is not a keyword in c?

637


What is uint8 in c?

629


Is main is user defined function?

583


How can you access memory located at a certain address?

656


Do character constants represent numerical values?

831


hi any body pls give me company name interview conduct "c" language only

1652


Which function in C can be used to append a string to another string?

637


How can I find out the size of a file, prior to reading it in?

610


#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??

1531


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

970