__Count Odd Even Difference __

__Count Odd Even Difference__

Given an array , write a program to Count Odd Even Difference . we have to find the difference of count of odd and count of even .

**Note : **You are expected to write code in the countOddEvenDifference function only which will receive the first parameter as the number of items in the array and second parameter as the array itself. you are not required to take input from the console.

Sample Input**input 1 :** 8**input 2 :** 10 20 30 40 55 66 77 83

Output

-2

**Explanation:- ** count of odd number are 3 { 55 ,77,83 } and count of even numbers are 5 { 10,20,30,40,66 } . So the difference is ( 3-5 = -2 ) .

__Count Odd Even Difference __

__Count Odd Even Difference__

__The objective of the code is to find the difference between count of odd numbers and count of even numbers .__

__C++ Code:-__#include<bits/stdc++.h>

using namespace std;

int countOddEvenDifference(int n, int a[])

{

int count_odd=0, count_even=0;

for(int i=0;i<n;i++)

{

if(a[i]%2==0)

{

count_even+=1;

}

else

count_odd+=1;

}

return (count_odd-count_even);

}

// Driver function

int main()

{

int n;

cin>>n;

int a[n];

for(int i=0;i<n;i++)

{

cin>>a[i];

}

cout<<countOddEvenDifference(n,a);

return 0;

}

__Output:-__8

10 20 30 40 55 77 60 83

-2

__Companies interview:-__- Swap adjacent characters
- Double the vowel characters
- Check valid parenthesis
- Print the characters with their frequencies
- Find closest value
- Word Count
- Program of CaesarCipher
- Program to find the perfect city
- Annual Day | Tech Mahindra coding question
- Find the number of pairs in the array whose sum is equal to a given target.

__Wipro :-__

- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID

__Infytq :-__

__Key Points;-__

__Hackerrank:-__

- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution

__C-tutorial:-__

- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array

__See more:-__- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation

## 0 Comments