Starting from:
$30

$24

Computer Programming Lab #6 Solution

    1. Write a C program that finds whether the sum of index values of a 2-dimensional array is even and finds the average of these index values.

Expected Output















The index values that satisfy the rule are [0][0], [0][2] and [1][1] index values. Since the sum of these indexes is even numbers, it satisfies the rule. The average of the values in these indexes is 20.3.

    • You should print your result as float on the screen.

    • 1 digit after the decimal point is enough.

    • Call the average_finder (...) function from within the main (...) function.

    • When creating the values in the matrix, you should calculate each index value as

2  2 − 3. You should take the starting value as 1 and run it by incrementing it by 1 each loop. As seen in the example 2 ∗ 12 − 3 = −1.

    • You can use 1 extra function, except the average_finder (...) function, which is called from the main function.

    • You can only use 1 condition statement while checking the desired rule.

You should create a 3x5 and 4x9 matrix and fill in the index values according to the calculation rule given. Then you should find the result in accordance with the desired rules within the average_finder (...) function.

    2. Write the C program that combines the 2 different strings given. The rule that you must follow when combining is that instead of adding one after the other, you need to combine the indexes by typing each pair of matching letters together.

For Example,

Let the strings "abcdefg" and "1234". When we combine them, we should get a result string "a1b2c3d4efg".

        ◦ As seen in the example, the lengths of the strings should be different.

        ◦ If the end of the short string is reached during concatenation, the long string should be copied in the same way.

Function prototype;

void intervew (const char s1, const char s2, char * s3);



P.S. Perform these tasks respectively in a single program.

More products