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 / goloap
int countchtr(char *str, char ch)
{
int count=0;
char *itr = str;
while (*itr != '\0')
{
if(*itr == ch)
{
count++
}
itr++;
}
return count;
}
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is break in c?
What is the process to generate random numbers in c programming language?
What is wrong in this statement?
Why is #define used?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
What is a program?
Difference between Shallow copy and Deep copy?
Explain what are multidimensional arrays?
can we have joblib in a proc ?
Explain pointer. What are function pointers in C?
How can a number be converted to a string?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What are the functions to open and close the file in c language?
When is the “void” keyword used in a function?
Explain pointers in c programming?