Question: Please Write in Program C, Thank you! Question 1: Function that changes three variables: Write a function (named three) that takes two arguments: a pointer

Please Write in Program C, Thank you!

Question 1: Function that changes three variables:

Write a function (named "three") that takes two arguments: a pointer to an int and a pointer to a char. The funtion should return a float.This function should examine the value pointed at in the first argument. If the value is even, set the value pointed at by the second argument to be an 'E', if it is odd, set the second value to 'O'. Then return the integer pointed at by the first argument reduced by 1 as a float (you will need to cast the result). Finally, increment the first integer.

I've already included the include stdio.h declaration, but you need to supply the definition for "three" (and nothing else, the testcases already have a main function).

Example function usage:

int a = 7;

char b;

float c = three(&a, &b);

printf("%d %c %.1f", a, b, c); // Should print: 8 O 6.0

Question 2: Find extremes

Write a void function, called "find_extremes", that takes 3 arguments:

An int array.

An int representing the size of the array.

A pointer to an int where you should store the largest value in the array.

A pointer to an int where you should store the smallest value in the array.

The array will at least be of size one.

Question 3: Count Letters

Write a void function, called "count", that takes 5 arguments.

Arguments:

A char array.

An int representing the size of the char array.

A pointer to an int, that you should store the number of letters in the char array (uppercase and lowercase).

A pointer to an int, that you should store the number of digits in the char array (0-9).

A pointer to an int, that you should store the number of other characters (non-letters, non-digits) in the char array.

Question 4: Number of Matches

Write a function, named "matches", that takes 4 arguments, and returns an int.

Arguments:

char array (called array_1)

char array (called array_2)

int size of each array (called size)

pointer to char (called first_match_ptr)

The function should compare the two arrays at each index, and if both arrays have the same character, it should increment a tally. The tally of all the matches should be returned. Additionally, the first characters that match should be stored in the address pointed at by the 4th argument. However, if there are no matches, set the first_match pointer to a pound character ('#').

Example:

char array_1[5] = {'a', 'a', 'b', 'c', 'd'};

char array_2[5] = {'a', 'a', 'z', 'y', 'd'};

char first_match;

int result = matches(array_1, array_2, 5, &first_match);

// result should be 3 because matches at index 0, 1, and 4

// first_match should be 'a' because that was the first match found.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!