write a program to display all odd numbers between a and b
Answers
Answered by
0
Answer:
U haven't wrote language name so i am just writing logic
Int a,b;
take input of a & b
for(int i=a;i<=b;i++){
if(i%2 == 0){
print i
}
else{
continue;
}
}
Read my bio
Answered by
3
a = int(input("Enter the lower value: "))
b = int(input("Enter the upper value: "))
for i in range(a, b):
if i%2 != 0:
print(i)
Once the lower and upper values are input, you start a loop, giving the lower value as the start value and the upper value as the stop value.
The changing variable 'i', takes up all the values between the given range.
If it satisfies the condition of being an odd number, [checking for divisibility by two], it gets printed.
Attachments:
Similar questions