Funtion print (n) if n>1: print (n/2) print (n/2) for i = 1 to n print_line("print me") how many times the above function prints "print me"?
Answers
Answered by
3
Answer:
function prints "print me" n times.
Explanation:
this function has defined a loop in it.
there are two conditions in this loop.
first condition is when n>1 function will print "print me"
in the second condition function prints "print me" when i=1
and finally from 1 to n function call function prints "print me"
hence this loop runs n time and
function prints "print me" n times.
Answered by
0
The above code prints "print me" (N) times for N>=1 and never prints "print me" for n<1
Explanation:
- In the above code, the loop body executes if the value of n is greater than or equal to 1 because the loop condition starts for the value of 1 and ends on every value of N if N>=1.
- For example if the user gives 5 value for the N variable then the "print me" print 5 times but if the user gives 0 value for the N variable then it does not prints "print me" for a single time.
- So the above codes prints the "print me" for n times if the value of n >= 1 but it does not print a single time for the value of n<1 because if the value of n is less than 1 then the loop condition is false in the first steps.
Learn More:
- For Loop : brainly.in/question/8823865
- Loop : brainly.in/question/14673533
Similar questions