PLEASE EXPLAIN THE ANSWER The file data1 contains 0 3 6 9 12

PLEASE EXPLAIN THE ANSWER

The file data1 contains: 0 3 6 9 12
The file data2 contains: 10 8 6 4 2
The file data3 contains: 20 10 0 20 80
Give the output when run with: ./a.out data1 data2 data3

}

Solution

Output

$ ./a.out data1 data2 data3
20
13
0
80
160
3 and 12

Explaination:

at the Begining
sum1=0
sum2=0

there are five rounds of for-loop

Round 1:
-------
num1 = 0
num2 = 10
num3 = 20

here (num1 < num2) hence
print num1+num3=0+20=20
sum1 = sum1+num1=0+0=0


Round 2:
-------
num1 = 3
num2 = 8
num3 = 10

here (num1 < num2) hence
print num1+num3=3+10=13
sum1 = sum1+num1=0+3=3

Round 3:
-------
num1 = 6
num2 = 6
num3 = 0

here (num1 IS NOT < num2) hence
print num2 * num3=6*0=0
sum2 = sum2 + num2 = 0+6=6

Round 4:
-------
num1 = 9
num2 = 4
num3 = 20

here (num1 IS NOT < num2) hence
print num2 * num3=4*20=80
sum2 = sum2 + num2 = 6+4=10

Round 5:
-------
num1 = 12
num2 = 2
num3 = 80

here (num1 IS NOT < num2) hence
print num2 * num3=2*80=160
sum2 = sum2 + num2 = 10+2=12

hence at the end, sum1=3, sum2=12

PLEASE EXPLAIN THE ANSWER The file data1 contains: 0 3 6 9 12 The file data2 contains: 10 8 6 4 2 The file data3 contains: 20 10 0 20 80 Give the output when ru
PLEASE EXPLAIN THE ANSWER The file data1 contains: 0 3 6 9 12 The file data2 contains: 10 8 6 4 2 The file data3 contains: 20 10 0 20 80 Give the output when ru

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site