Question & Answer: a) Write a complete and correct C function named findch with the following properties. 1) Accepts two parameters-a…..

Problem H5 010 points) a) write a complete and correct named find ch with the following properties 1) Accepts two parameters-a string and a single 2) Searches 3) Returns the string to see if the exists inside the string via the return statement one of the following possible values: if character was found location (index) of the first occurrence of the character within the string character was not found integer -1 (negative one) to indicate failure function should be silent, i it should not prompt for input nor should in print anything. You assume the input string argument is terminated properly with a may Examples: Suppose string is Portland, Oregon and character is a returned value should be 5 Suppose string is zebra and character is f returned value should be -1 The following C function uses array notation. Re-write the to replace all of the array n (i.e., brackets and indices) with its pointer equivalent (i.e., and offsets). void fun (int x[], int y[J, int size for (int k 03 k size-1 k++) x[k] x[k+1]

Write a complete and correct C function named findch with the following properties:…

a) Write a complete and correct C function named findch with the following properties. 1) Accepts two parameters-a string and a single character Searches the string to see if the given character exists inside the string Returns via the return statement one of the following possible values: if character was found rightarrow location (index) of the first occurrence of the character within the string if character was not found rightarrow integer -1 (negative one) to indicate failure The function should be silent, i.e., it should not prompt for input nor should in print anything. You may assume the input string argument is terminated properly with a NUL ( ) Suppose string is “Portland, Oregon” and character is a rightarrow returned value should be 5 Suppose string is “zebra” and character is ‘f’ rightarrow returned value should be -1 The following C function uses array notation. Re-write the function to replace all of the array (i.e., brackets and indices) with its pointer equivalent (i.e., *and offsets). void fun (int x[], int y[], int size) { for (int k = 0:k size-1 k++) y[k] = x[k] + x[k+1];

Expert Answer

 #include <stdio.h>

int findch(char *string, char toFind) {
int i=0;
while(string[i] != ‘’) {
if(string[i] == toFind) {
return i;
}
i++;
}
return -1;
}

void fun(int *x, int *y, int size) {
int k=0;
for(k=0; k<size-1; k++) {
*(y+k) = *(x+k) + *(x + k +1);
}
}

int main()
{
printf(“Seaching ‘a’ in ‘Portland, Oregon’ : %dn”, findch(“Portland, Oregon”, ‘a’));
printf(“Seaching ‘f’ in ‘zebra’ : %dn”, findch(“zebra”, ‘f’));

return 0;
}

Still stressed from student homework?
Get quality assistance from academic writers!