answersLogoWhite

0


Best Answer

#include

using std::cout;
using std::endl;

int main()
{
int arr[] = {2, 45, 34, 56, 56};//you define here your array of even and odd numbers
int arrSize = sizeof arr/sizeof arr[0];

int numEven = 0;
int numOdd = 0;
for (int i = 0; i < (arrSize - 1); i++)
{
if (arr[i] % 2 == 0)
{
numEven++;

}
else
{
numOdd++;

}

}

cout << endl << "Number of even numbers: " << numEven
<< endl << "Number of odd numbers: " << numOdd
<< endl;

system("PAUSE");
return 0;

}

User Avatar

Wiki User

βˆ™ 15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Counting even and odd numbers algorithm?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you find odd or even in n number of value?

-- First of all, if the number is a fraction or a decimal, then don't worry about it. Only whole numbers are considered odd or even. -- All multiples of 2 are even numbers, and that's easy to recognize. It doesn't matter how big the number is, or how many digits it has. You only have to look at the last digit (the one on the right-hand end). If that digit is 2, 4, 6, 8, or 0, then the whole big number is even. Otherwise it's odd.


How do you Write a C program to print a Series of Odd Numbers and Even Numbers.?

Reference:http:cprogramming-bd.com/c_page2.aspx# strange number


What is odd loop?

Move the print out requesting the user to enter an integer outside of the for loop and it will only print once instead of each time around the loop. You'll need a way to save the even and odd numbers that you detect in the loop. One way is to have separate arrays to hold the even and the odd numbers as you go around the loop. Then at the end of the loop you can have more loops to print the contents of one array and then the contents of the other array. Another way is to concatenate the number onto separate Strings (even and odd) to be displayed after the data gathering loop.


Without using mod operator find the even or odd?

import java.util.*; class Demo { public static void main(String args[]) { System.out.println("Even Numbers Are "); for (int i=1;i&lt;=20;i++) { System.out.print(" "+(2*i)); } System.out.println("\n \n Odd Numbers Are "); for(int j=0;j&lt;=20;j++) { System.out.print(" "+((2*j)+1)); } } }


Write an algorithm find out the sum of first n odd numbers?

Algorithm: sum_evenInput: an integer, n, such that n>0Output: the sum of all even integers within the open range (1:n)sum := 0val := 2while (val < n) do{sum := sum + valval := val + 2}return sumNote that you explicitly specified between 1 and n, which literally means both 1 and n should be excluded from the sum. 1 would be excluded anyway since it is not an even number, however if we wish to include n, then use the following algorithm instead:Algorithm: sum_evenInput: an integer, n, such that n>0Output: the sum of all even integers within the half-open range (1:n]sum := 0val := 2while (val

Related questions

How many counting numbers less then 30 are composite but nei ther odd or even?

None of them. All counting numbers are either odd or even.


How many counting numbers less than 30 are composite but neither odd nor even?

None. All counting numbers are even or odd.


What are the Even and odd numbers to 100?

1, 3, 5, 7, 9 counting by twos to 99 are the odd numbers. 2, 4, 6, 8, 10 counting by twos to 100 are the even numbers.


How many counting numbers less than 30 are either odd or even but not both?

All numbers are either odd or even, none are both, so less than 30 there are 29 counting numbers that are either odd or even but not both. (Assuming you mean starting to count with 1.)


What is the sum of the first 500 odd counting numbers?

The sum of the first 500 odd counting numbers is 250,000.


What are the different types of numbers?

irrational numbers odd numbers even numbers whole numbers prime numbers composite numbers counting numbers


Is 1.8 a even or odd number?

Niether it wouldn't be counted in a group of odd and even numbers it would only be counted as a odd and even if you was counting in decimals


Which kind of number is divisible by 2 - odd numbers - all counting numbers - even numbers - whole numbers?

Only even numbers are divisible by two. If you have an odd number, for example 3, and divide by two, you will get 1 with a remander of 1.


Is the odd counting numbers closed for addition?

No.


Can 5 odd numbers that if you add them make 32?

37


What the pattern called even odd numbers?

There is no such pattern because there are no even odd numbers. Odd numbers, by definition, are odd and therefore, not even.


How will I choose a numbers to add from the set of counting numbers 1-10 with a sum of number that are not divisible by 2?

Choose one odd and one even