Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Monday, 14 November 2016

URI-1070

URI Online Judge | 1070

Six Odd Numbers

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
Read an integer value and print the 6 consecutive odd numbers from X, a value per line, including if it is the case.

Input

The input will be a positive integer value.

Output

The output will be a sequence of six odd numbers.
Input SampleOutput Sample
89
11
13
15
17
19

Solution...

#include<stdio.h>
int main()
{
    int a,i,j=0;
    scanf("%d",&a);
    if(a%2==0){
        for(i=a+1;j<6;i=i+2){
            printf("%d\n",i);
            j++;
        }

    }
    if(a%2!=0){
        for(i=a;j<6;i=i+2){
            printf("%d\n",i);
            j++;
        }
    }
    return 0;
}

No comments:

Post a Comment