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
a small change..............
#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 ? | 3 Yes | 0 No |
Post New Answer View All Answers
What are the modifiers available in c programming language?
What are different types of operators?
What is omp_num_threads?
What are the different types of errors?
What is a stream in c programming?
What is zero based addressing?
What language is lisp written in?
What are the advantages and disadvantages of a heap?
#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??
What is the difference between mpi and openmp?
Write a program to print ASCII code for a given digit.
How can a program be made to print the line number where an error occurs?
What does s c mean in text?
How does placing some code lines between the comment symbol help in debugging the code?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com