Answer to Question #317591 in C++ for Zaki

Question #317591

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.

1
Expert's answer
2022-03-24T11:26:58-0400
#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;
}




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