URI - BEECROWD - BEE 1067 - Odd Numbers Solution in C,C++,Python

 URI - BEECROWD - BEE 1067 - Odd Numbers Solution in C,C++,Python |  URI - BEECROWD - BEE Online Judge Solution 1067 - Odd Numbers

Read an integer value (1 <= <= 1000).  Then print the odd numbers from 1 to X, each one in a line, including X if is the case.

Input

The input will be an integer value.

Output

Print all odd values between 1 and X, including if is the case.

Input SampleOutput Sample

8

1
3
5
7

 URI - BEECROWD - BEE 1067 - Odd Numbers Solution in C,C++,Python | URI - BEECROWD - BEE Online Judge Solution 1067 - Odd Numbers :

                                        Demonstration:

Any integer that cannot be divided exactly by 2 is an odd number.
Here we apply a range-based for loop which provides all the integers available in the input interval.
After this, checking the condition for odd numbers are applied and printing these values. 
N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

   URI - BEECROWD - BEE Problem 1067 Solution in C :   

   URI - BEECROWD - BEE Online Judge 1067 Solve  in C :                                       
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%2!=0){
            printf("%d\n",i);
        }
    }
}

0 Response to URI - BEECROWD - BEE 1067 - Odd Numbers Solution in C,C++,Python

Post a Comment