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
#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;
}
Comments
Leave a comment