What is the calculated value y in the following program incl

What is the calculated value y in the following program? #include void main (void) {WDTCTL = WDTPW | WDTHOLD; int count; int y[5]; int x[] = {1, 1, 0, 1, 1}

Solution

Answer: y value is {0,0,0,-1,1}

in for loop , we are calculating the value and assigning that value to each location in y starts from 0 to 4.

for loop will run 5 iterations starts from 0 to 4.

Inside for loop, we are picking value from starting from array x and picking value from last from array h and multiplying both and storing into y.

In first iteration y[0] = x[0] * h[4] = 1 * 0 = 0

In second iteration y[1] = x[1] * h[3] = 1 * 0 = 0

In first iteration y[2] = x[2] * h[2] = 0 * 0 = 0

In first iteration y[3] = x[3] * h[1] = 1 * -1 = -1

In first iteration y[0] = x[4] * h[0] = 1 * 1 = 1

So finally y value is {0,0,0,-1,1}

 What is the calculated value y in the following program? #include void main (void) {WDTCTL = WDTPW | WDTHOLD; int count; int y[5]; int x[] = {1, 1, 0, 1, 1} So

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site