Does the following program print de int main int i result 0

Does the following program print? .de int main() {int i, result = 0. a[] = {5, 4, 3, 2}; for(i = 0; i

Solution

9)Answer is 9

Reason :

the for loop will execute until the \' i \' value become 2.

As i=0 for the first time of iteration then result is 5(as a[0]=5 so which is added to the result(which is 0))

so

result=result+a[0];

result=0+5;

result=5

Now incremented the i value from 0 to 1

as i=1 ,now result =result+a[1]=5+4=9

result=9

Incremention the i value from 1 to 2

as i==2 the for loop will break and control will come out of the loop.so the final result value is 9

___________________________________

10)

Wookie[0] = C
Wookie[i] = w
Sister[i+1] = space
Jedi[2+i] = a
Jedi[i-3] = O

Reason:

Array index starts from 0 so,

Wookie[3]=C

Wookie[3]=w

Sister[4]=space

Jedi[5]=a

Jedi[0]=O

______________Thank You

 Does the following program print? .de int main() {int i, result = 0. a[] = {5, 4, 3, 2}; for(i = 0; i Solution9)Answer is 9 Reason : the for loop will execute

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site