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
Differentiate between the = symbol and == symbol?
c program to compute AREA under integral
code for quick sort?
What is union in c?
What is the equivalent code of the following statement in WHILE LOOP format?
What is the use of volatile?
Is c# a good language?
Explain how can I manipulate strings of multibyte characters?
Hi can anyone tell what is a start up code?
What is c language & why it is used?
Why enum is used in c?
Explain how do you print an address?
What is break in c?
Is this program statement valid? INT = 10.50;
When should the volatile modifier be used?