Skip to main content

Accenture

Accenture OA-25 2024

Problem Description

An odd number is an integer which is not a multiple of 2. You are required to implement the following function:
Int SumOddlntegers(int arr[], int n);
The function accepts an integer array 'arr' of length 'n' as its argument. You are required to calculate the sum of all odd integers in an array 'an' and return the same.

Note:
An array can have negative integers
Computed values lie within the integer range

Input Format:

  • The first line of input contains an integer n denoting the length of the array arr.
  • The second line contains n space-separated integers, representing the elements of the array arr.

Output Format:

Print a single integer, the sum of all odd integers in the array.

Constraints:

  • 1 ≤ n ≤ 10^5
  • -10^9 ≤ arr[i] ≤ 10^9

Example

Sample Input:

5
1 2 3 4 5

Sample Output:

9

Explanation:
The odd integers in the array are 1, 3, and 5. The sum of these odd integers is 9.