# URI Online Judge Solution 1071 Sum of Consecutive Odd Numbers I – Solution in C, C++, Java, Python and C#

### URI Online Judge Solution 1071 Sum of Consecutive Odd Numbers I – Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1071 Sum of Consecutive Odd Numbers I | Beginner

Problem Name: 1071 Sum of Consecutive Odd Numbers I
Problem Number : URI – 1071 Sum of Consecutive Odd Numbers I
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)

### URI Solution 1071 Sum of Consecutive Odd Numbers I Code in C:

``#include <stdio.h>int main(){ int x, y, tmp = 0, i; int min, max; scanf("%d%d", &x,&y); if(x < y){  min = x;  max = y; }else{  max = x;  min = y; } for(i = (min + 1); i < max; ++i) {  if(i % 2 == 1 || i % 2 == -1){   tmp += i;  } } printf("%dn", tmp); return 0;}``

### URI Solution 1071 Sum of Consecutive Odd Numbers I Code / URI 1071 solution in CPP:

``#include <iostream>using namespace std;int main(){ int x, y, tmp = 0; int min, max;  cin >> x >> y;  if(x < y){  min = x;  max = y; }else{  max = x;  min = y; }  for(int i = (min + 1); i < max; ++i) {  if(i % 2 == 1 || i % 2 == -1){   tmp += i;  } }  cout << tmp << endl;  return 0;}``

### URI Solution 1071 Sum of Consecutive Odd Numbers I Code / URI 1071 solution in Java:

``/*    6 -5  5    15 12  13 */import java.util.Scanner;public class Main { public static void main(String[] args) {  int X, Y, total = 0;  Scanner input =new Scanner(System.in);  X = input.nextInt();  Y = input.nextInt();  if (X > Y) {   for (int i = X - 1; i > Y; i--) {    if (i % 2 != 0) {     total += i;    }   }  }else {   for (int i = Y - 1; i > X; i--) {    if (i % 2 != 0) {     total += i;    }   }  }  System.out.print(total+"n"); }}``

### URI Solution 1071 Sum of Consecutive Odd Numbers I Code / URI 1071 solution in  C# (C Sharp):

Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks

Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1071 Sum of Consecutive Odd Numbers I code in C, URI 1071 code in C++, URI 1071 Sum of Consecutive Odd Numbers I  solution in C, URI solution, URI 1071 solution in C,URI 1071 solution in C++-CPP,URI 1071 solution in C# (C sharp),URI 1071 solution in Java,URI 1071 solution in Python,