Write a program in C++ that ask the user to type 10 integers. The program must compute how many even and odd numbers were entered along with number that are divisible by 7.
#include <iostream>
using namespace std;
int main() {
int num, odd=0, even=0, num7=0, i=0;
cout<<"Enter 10 integers: "<<endl;;
while(i<10){
cout<<i+1<<") ";
cin>>num;
if(num%2)
even++;
else
odd++;
if(num%7==0)
num7++;
i++;
}
cout<<"----------------------------------------"<<endl;
cout<<"Odd: "<<odd<<endl;
cout<<"Even: "<<even<<endl;
cout<<"Number that are divisible by 7: "<<num7<<endl;
return 0;
}
Comments
Leave a comment