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 / jagjit
#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 ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why is c called "mother" language?
what type of questions arrive in interview over c programming?
The statement, int(*x[]) () what does in indicate?
Is int a keyword in c?
Explain c preprocessor?
Is file a keyword in c?
What is the difference between exit() and _exit() function?
Explain bitwise shift operators?
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
In a byte, what is the maximum decimal number that you can accommodate?
Write a Program to find whether the given number or string is palindrome.
When c language was developed?
I have a varargs function which accepts a float parameter?
what is recursion in C
Write a program with dynamically allocation of variable.