In: Computer Science
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Since programming language is not mentioned in the question, So I am assuming it as python language.
Below is the python code for mentioned problem statement:
In this we use for loop with range and also implement with while loop :
# Program will start from main function
if __name__ == '__main__':
start_num = 64
end_num = 339
# declare a empty list
result_list = []
# using for loop iterate the number from 64 to 339 using range(start , end)
for x in range(64, 340):
# print("num : ", x)
# Append the number in a list
result_list.append(x)
# Showing the result
print("List of numbers using for loop : ", result_list)
# Using while loop:
result_list = []
while start_num <=339:
result_list.append(start_num)
start_num = start_num + 1
print("List of numbers usi g while loop : ", result_list)

