Answer to Question #189801 in C++ for ekmal

Question #189801

write a complete c++ program that accepts an integer n . the program will then reads in n integer numbers. count and display the number of odd integers.


1
Expert's answer
2021-05-06T04:24:04-0400
#include <iostream>


using namespace std;


int main(){
    int n; 
	int integerValue;
	int numberOddIntegers=0;
	cout<<"Enter the number of integers: ";
	cin>>n;
    for(int i = 0; i < n; i++){
		cout<<"Enter integer value "<<(i+1)<<": ";
		cin>>integerValue;
		//count and display the number of odd integers.
		if(integerValue%2!=0){
			numberOddIntegers++;
		}
    }


	cout<<"The number of odd integers is: "<<numberOddIntegers<<"\n\n";
	
	system("pause");
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS