Computer Science, asked by ranajanasingh1287, 4 months ago

ln order to print series of odd numbers from 1 to N , i should be using :​

Answers

Answered by Anonymous
0

Explanation:

To print the odd numbers in C

#include <stdio.h>

#include <conio.h>

void main()

int i,n;

printf("\nENTER A NUMBER: ");

scanf("%d",&n);

printf("\nODD NUMBERS BETWEEN 1 AND %d ARE: \n",n);

for(i=1;i<=n;i+=2)

Input upper limit to print odd number from user. Store it in some variable say N .

Run a loop from 1 to N , increment loop counter by 1 in each iteration. ...

Inside the loop body check odd condition i.e. if a number is exactly divisible by 2 then it is odd.

num = int(input("Enter a number: ")) mod = num % 2 if mod > 0: print("This is an odd number. ") else: print("This is an even number. ")Programming Example

n=int(input("Enter the Limit"))

if n%2==0:

for i in range(n-1,0,-2):

print(i)

else:

for i in range(n,0,-2):

print(i)

The even numbers from 1 to 100 are: 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98 and 100.

Similar questions