posted 1 year ago

- 1

I added code tags around you code so from next time please alway post code in code tags and quote your source. Refer Use Code Tags and Quote Your Sources

This is how It gets executed:

At beginning x = 0 and y = 0.

00

11

21

32

42

This is how It gets executed:

At beginning x = 0 and y = 0.

value of x | value of y | Is x < 5 ? | y = x - y | Prints x and y | x = x + 1 |
---|---|---|---|---|---|

0 | 0 | 0 < 5? = true | y = 0 - 0 means y = 0 | 0 0 | x = 0 + 1 means x = 1 |

1 | 0 | 1 < 5? = true | y = 1 - 0 means y = 1 | 1 1 | x = 1 + 1 means x = 2 |

2 | 1 | 2 < 5? = true | y = 2 - 1 means y = 1 | 2 1 | x = 2 + 1 means x = 3 |

3 | 1 | 3 < 5? = true | y = 3 - 1 means y = 2 | 3 2 | x = 3 + 1 means x = 4 |

4 | 2 | 4 < 5? = true | y = 4 - 2 means y = 2 | 4 2 | x = 4 + 1 means x = 5 |

5 | 2 | 5 < 5? = false so control comes out of while loop | --- | --- | --- |

**Output:**00

11

21

32

42