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