please solve this give me output for this
Attachments:
Answers
Answered by
1
Hi,
Please check screenshot for output:
Here I want to show you what actually is inside those varuables.
sum(0) = sum (0) + a (1)
sum (1) = sum (1) + a (3)
sum (4) = sum 4 + a (5)
sum (9) = sum (9) + a (7)
sum (16) = sum (16) + a (9); ( $a<=8 condition will fail here because a is greater than 8)
sum (16)
a (9)
Attachments:
nitish8089:
i have two page view and here all want's proof of output
Answered by
2
output:
16
9
as you are get after the for loop there is no braces so only one statement run ...
$Sum=$Sum+$a..
and a values..
a=1
a=3
a=5
a=7
and for the value of a=9
the loop will not execute further so
$Sum=1+3+5+7
$Sum=16
$a=9
16
9
as you are get after the for loop there is no braces so only one statement run ...
$Sum=$Sum+$a..
and a values..
a=1
a=3
a=5
a=7
and for the value of a=9
the loop will not execute further so
$Sum=1+3+5+7
$Sum=16
$a=9
Similar questions
Hindi,
7 months ago
English,
7 months ago
Computer Science,
7 months ago
Computer Science,
1 year ago
Science,
1 year ago
French,
1 year ago