Answer to Question #188834 in C++ for naura

Question #188834

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-07T06:06:28-0400
#include <iostream>


using namespace std;


int main(){
    int n; 
	int v;
	int oddCounter=0;
	cout<<"Enter the number of values: ";
	cin>>n;
    for(int i = 0; i < n; i++){
		cout<<"Enter value "<<(i+1)<<": ";
		cin>>v;
		if(v%2!=0){
			oddCounter++;
		}
    }
	cout<<"Total number of odd values = "<<oddCounter<<"\n\n";
	
    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
APPROVED BY CLIENTS