wap to input a number and print all the odd number up to that number
Answers
Answered by
0
Answer:
Run a loop from 1 to N , increment loop counter by 1 in each iteration. The loop structure should look like for(i=1; i<=N; i++) . Inside the loop body check odd condition i.e. if a number is exactly divisible by 2 then it is odd. Which is if(i % 2 !
Explanation:
mark me as brilliant please
Answered by
3
Language:
Python
Program:
a,i,sum=int(input("Enter a number:")),0,0
while i<=a:
if i%2!=0:
sum+=i
i+=1
print(sum)
Explanation:
Program checks if the number is odd with the help of while loop and adds the number upto the input number.
Attachment:
Attachments:
Similar questions