Ask Question
23 April, 18:26

Write a complete C program to run on the MSP432 platform to do the following:

Declare an array of size 3 x 7 of type uint8_t. Use loops to initialize each array element to contain the value of the sum of its indices (e. g., for element arr[2][5], write a value of 7 to arr[2][5], write a value of 7 to arr[1][6], etc.). Use additional loops to go through the array and test each value - if a value is not a multiple of 5, add that value to a cumulative sum and write a zero to the array element. If it is a multiple of 5, leave it untouched. Print the final result as a 16-bit integer value (the sum of the array elements not multiples of 5). Be sure to compile it in CCS to catch any syntax errors.

+3
Answers (1)
  1. 23 April, 21:42
    0
    The C code is given below with appropriate comments

    Explanation:

    #include

    int main ()

    {

    //array declaration

    int arr[3][7], cumulativeSum = 0;

    //initialize the array

    for (int i=0; i<3; i++)

    {

    for (int j=0; j<7; j++)

    {

    arr[i][j] = i+j;

    }

    }

    //calculate the cumulative sum

    for (int i=0; i<3; i++)

    {

    for (int j=0; j<7; j++)

    {

    if ((arr[i][j] % 5) ! = 0)

    {

    cumulativeSum + = arr[i][j];

    arr[i][j] = 0;

    }

    }

    }

    //display the final array

    printf ("The final array is: / n/n");

    for (int i=0; i<3; i++)

    {

    for (int j=0; j<7; j++)

    {

    printf ("%d ", arr[i][j]);

    }

    printf ("/n");

    }

    //display the cumulative sum

    printf ("/nCumulative Sum = %d", cumulativeSum);

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a complete C program to run on the MSP432 platform to do the following: Declare an array of size 3 x 7 of type uint8_t. Use loops to ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers