Question
Programming Exercise 1: Passing a Two-dimensional Array
Write a program that will read in 12 integer values into a 3 x 4 two-dimensional array (i.e., an array of 3 arrays of 4 integers). The values should be entered via standard input. The main program should then call a function sum that will calculate the sum of the values and return this sum back to the main program. The main program will output the sum. This program shows that you can successfully pass a two-dimensional array in C.

Programming Exercise 2: Inner Product of Two Arrays
Write a program that will input two arrays of information. Each array will contain exactly 4 floating point values. Your program will enter these values from standard input. Once the values have been read in, your program should call a function that will compute the inner product of these two arrays. The function should return the value back to the main program. The main program will then print out the value. You should not print the value out inside the inner product function. The inner product of two arrays is a single number obtained by multiplying corresponding elements and then adding up their sums.

E.g., if array u = (5, 1, 6, 2) and array v = (1, 2, 3, 4) then the inner product is 33
because (5 * 1) = 5 (1 * 2) = 2 (6 * 3) = 18 (2 * 4) = 8
and 5 + 2 + 18 + 8 is 33.

Your main function will call a function called inner that has the following declaration:
float inner ( float u[], float v[], int size ) ;

Programming Exercise 3: Unfilled Box
Your task is to read a pair of positive integers, L and H (in this order), from standard input. Both L and H will be less than 21. Your program then prints out an empty box of asterisks with L horizontal stars and H vertical stars. The box is empty. For example, if the input data is 6 and 4 then the output should be:

******
*       *
*       *
******
The minimum values of H and L will be 1. Your program must output a 1 × 1 box correctly when prompted.
Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

1.

#include <stdio.h>

int sum(int array [3][4]);

int main(int argc, char* argv[]) {
   
    int array [3][4];
   
    int i;
    int j;
    int input;
   
    for (i = 0; i < 3; i++) {      
       for (j = 0; j < 4; j++) {
            scanf("%d", &input);
            array[i][j] = input;
       }
    }
   
    printf("sum: %d\n", sum(array));
   
    return 0;
}
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files:
Solution.zip
Purchase Solution
$28.00
Google Pay
Amazon
Paypal
Mastercard
Visacard
Discover
Amex
View Available Computer Science Tutors 645 tutors matched
Ionut
(ionut)
Master of Computer Science
Hi! MSc Applied Informatics & Computer Science Engineer. Practical experience in many CS & IT branches.Research work & homework
5/5 (6,806+ sessions)
1 hour avg response
$15-$50 hourly rate
Pranay
(math1983)
Doctor of Philosophy (PhD)
Ph.D. in mathematics and working as an Assistant Professor in University. I can provide help in mathematics, statistics and allied areas.
4.6/5 (6,696+ sessions)
1 hour avg response
$40-$50 hourly rate
Leo
(Leo)
Doctor of Philosophy (PhD)
Hi! I have been a professor in New York and taught in a math department and in an applied math department.
4.9/5 (6,467+ sessions)
2 hours avg response

Similar Homework Solutions