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 / vignesh1988i
#include<stdio.h>
#include<conio.h>
int string(char *,char);
void main()
{
char str[100],ch;
int c;
printf("enter the string :");
gets(str);
printf("enter the character to be searched :");
scanf("5c",&ch);
c=string(&str[0],ch);
printf("the character %c occurs for %d times ",ch,c);
getch();
}
int string(char *a,char ch)
{
int count=0;
for(int j=0;*a!='\0';j++)
{
if(*a==ch)
{
count++;
*(a++);
}
}
return count;
}
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
What is #line?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
Explain is it better to bitshift a value than to multiply by 2?
Explain about the functions strcat() and strcmp()?
Tell me what is the purpose of 'register' keyword in c language?
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
how to write optimum code to divide a 50 digit number with a 25 digit number??
what are non standard function in c
What is line in c preprocessor?
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
What is scope rule in c?
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
Explain how do I determine whether a character is numeric, alphabetic, and so on?
What is floating point constants?