Computer Science, asked by aravindvilla23p98m3a, 1 year ago

Consider the following code: for i= m to n increment 2 { print "Hello!" } Assuming m < n and (m,n) are either both even or both odd, How many times will Hello be printed?

Answers

Answered by QGP
6
Hey There!! 

The word Hello! will be printed \boxed{\left(\frac{n-m}{2}\right)+1} number of times.   

Here's an example: Take m=3, n=9
Then i will take the following values: i=3,5,7,9 
Clearly there are 4 values, and 4=\frac{9-3}{2}+1

You can also check it with other possible values.

Hope it helps,
Purva
Brainly Community

Similar questions