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 will be the outcome of the following conditional statement if the value of variable s is 10?
Is register a keyword in c?
please give me some tips for the placement in the TCS.
What is structure of c program?
Do pointers need to be initialized?
What is the hardest programming language?
what is different between auto and local static? why should we use local static?
What is the value of h?
about c language
Explain the difference between call by value and call by reference in c language?
What does c mean?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What is the difference between array and structure in c?
explain what are pointers?
What is the use of getchar functions?