In this program, we will total numbers of odd numbers between 1-100 .
Steps to solve the program
- Create a count variable and assign its value equal to 0.
- Use for loop with the range function to iterate over values between 1-100.
- If a number is an odd number then add 1 to the count variable.
- Print the output.
count = 0
for i in range(1,101):
if i%2 != 0:
count += 1
print("Total numbers of odd number: ",count)
Output :
Total numbers of odd number: 50