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
What is the best way to store flag values in a program?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is pointer to pointer in c language?
How can I discover how many arguments a function was actually called with?
What is difference between scanf and gets?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
what is bit rate & baud rate? plz give wave forms
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
What is the difference between strcpy() and memcpy() function in c programming?
Differentiate between #include<...> and #include '...'
Can we increase size of array in c?
What are categories used for in c?
Explain what are binary trees?
What is the use of static variable in c?
Explain logical errors? Compare with syntax errors.