Answer:
#here is code in Python
#read the value of n
n=int(input("enter a number:"))
#print all the odd numbers
for i in range (1,n+1,2):
print(i,end = '')
Step-by-step explanation:
Read a number from user and assign it to variable "n".Then use a for loop to print all the odd numbers from 1 to n.We can use range() function to print this. here first number is starting of the range and second will be the end of the range. and 3rd one is the Increment to the iterator.
For example In the above code, 1 is the start point and n+1 will be the last. Here
loop will run till n only.Every time value of "i" is increased by 2.
Output:
enter a number:15
1 3 5 7 9 11 13 15