using repetition structure. Write a c program that will
accept five numbers. The program should count and output the
total count of even numbers and total count of add numbers.

Answer Posted / john

#include <iostream>
using namespace std;

int main(){
int array[5];
int i;
int evens = 0;
int odds = 0;

for(i = 0; i < 5; i ++){
cout << "Enter number: ";
cin >> array[i];
if(array[i] & 1)
odds++;
else evens++;
}

cout << "\nEvens: " << evens;
cout << "\nOdds: " << odds;
}

Is This Answer Correct ?    7 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character

3949


Code for Easily Using Hash Table?

2385


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

2142


write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used

4300


write a program to convert temperature from fa height into celcius and vise versa,use modular programming

2434






Code for Method of Handling Factorials of Any Size?

2000


develop a program to calculate and print body mass index for 200 employees

2208


Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

2042


Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).

3186


i don't know about working of nested for loop can any one help me

1788


find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L

2002


write a program that reads a series of strings and prints only those strings begging with letter "b"

2668


Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?

2557


How can I Draw an ellipse in 3d space and color it by using graph3d?

2130


write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n

2364