– 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?
A. (n – m + 1)/2
B. 1 + (n – m)/2
C. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd
D. (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd
Answer:B
– 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?
A. (n – m + 1)/2 B. 1 + (n – m)/2 C. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd D. (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd
Explanation: Number of term of an AP=N=(last-a)/d+1=>last=n, a=m, d=difference in series(Where m=1 and n=7).