What will be the value of and after the following code has b

What will be the value of and after the following code has been executed?

int ans = 10;

int x = 65;

int y = 65;

if (x <= y)

ans = x + y;

Solution

Answer:

First ans = 10 is initialized , x is initialized to 65 , y is initialized to 65. At the end condition is being checked : if(x<=y) , here x = 65 and y = 65 so condition is true as both x = y = 65. Then the new value of ans = 65+65 = 130. Hence the value of ans = 130.

What will be the value of and after the following code has been executed? int ans = 10; int x = 65; int y = 65; if (x <= y) ans = x + y;SolutionAnswer: First

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site