What will be the value of x after the following code runs:
func (y) {
while y > 0
y--
x += y
}
x = 0;
func (5)
Ans) 4
Explanation:
Here y =5 as function parameter .
The condition inside While evaluates true first statement inside While is y-- i.e 5-1 =4 and x=0 finally statement is x+=y
I.e x=x+y
X=0+4=4
Answer returns as 4
What will be the value of x after the following code runs: func (y) { while...