Which of the following pseudocode loops will print the odd integers from 25 to 45.
A) num = 25 |
B) | num = 25 while num <= 45 print num num = num + 1 end while |
C) | num = 1 while num <= 10 print num num = num + 2 end while |
B) | num = 25 while num <= 45 print num num = num + 2 end while |
The answer is option D.
num = 25
while num
<= 45
print num
num = num + 2
end
while
num starts from 25 and in the while loop the num is printed and is incremented by 2 to print all the odd numbers.
Which of the following pseudocode loops will print the odd integers from 25 to 45. A)...
python print ("num=", num) 12. (2) The following loop should print the squares of the odd numbers never ends. What is the error and how could it be fixed? num = 1 while num != 12: print (num ** 2) num += 2
Design (pseudocode)(name it Pattern) that uses nested loops to print out the following pattern. Document your code properly. 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Consider the following incomplete code segment, which is intended to print the sum of the digits in num. For example, when num is 12345, the code segment should print 15, which represents the sum 1 + 2 + 3 + 4 + 5. int num = 12345; int sum = 0; /* missing loop header */ { sum += num % 10; num /= 10; } System.out.println(sum); Which of the following should replace /* missing loop header */ so that the...
(+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100) to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0 (how many) Display the number of integers < 0 (how many) Display the...
python programming Which of the following code will print all odd numbers between 3 and 11, each number separated by a space as shown below 35 7 9 11 for i in range(3, 11, 1): if 1%2 ID: print(i, end = " for i in range(3, 10, 2): print(i, end = for i in range, 11, 2): if 152 == 0: print(i, end = "") for i in range 12, 1): print(i, end = "")
Write pseudocode while loop to sum all the values between 2 integers (A & B, input by the user), including A and B, and print the resulting sum. A must be less than B, otherwise print 0.
JAVA turn this psuedo code into java code. USING NO LOOPS! ALL LOOPS MUST BE TURNED INTO RECURSIVE CALLS. English: 1. Prompt for and read a number between 1 and 5. Repeat this step until the input is 1..5. 2. Repeat the following multiple times according to the number read in step 1. a. Read in a list of integers ending with a 0. The 0 marks the end of the input and is not considered part of the list...
Statement Given two non-zero integers, print "YES" if exactly one of them is positive and print "NO" otherwise Hint: You will need to use the following logical operators: and or Example input #1 -5 10 Example output #1 YES Example input#2 1 9:36 AM 10/1/2020 end og up delete home "brt so + backspace num lock 11 9
Task 4 Write a script that will print the following table using 2 loops (either for or while) 24 3 6 9 4 8 12 16 5 10 15 20 25
Python What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. s = 2 for n in range (1, 6): s = s + n print(s) b. s = 1 for n in range (1, 11): n = n + 2 s = s + n print(s) c. S = 1 for in range (1, 6) s = s + n n = n + 1 print(s, n) Rewrite the...