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 is .obj file in c?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
Is stack a keyword in c?
Explain what is the stack?
What are runtime error?
Why main is not a keyword in c?
What is uint8 in c?
Is main is user defined function?
How can you access memory located at a certain address?
Do character constants represent numerical values?
hi any body pls give me company name interview conduct "c" language only
Which function in C can be used to append a string to another string?
How can I find out the size of a file, prior to reading it in?
#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??
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping