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
What are the different properties of variable number of arguments?
What is the difference between memcpy and memmove?
Why is c so powerful?
What is advantage of pointer in c?
What is the maximum no. of arguments that can be given in a command line in C.?
What is structure in c definition?
Why main function is special give two reasons?
What is the ANSI C Standard?
What is the use of getchar functions?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
If null and 0 are equivalent as null pointer constants, which should I use?
explain what is fifo?
Can you write the algorithm for Queue?
What is 1f in c?
How can I get back to the interactive keyboard if stdin is redirected?