Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

18:42 ? my.unisa.ac.za l TelkomSA 3G 100% CO51511/102/1/2018 Question ld When ru

ID: 3705498 • Letter: 1

Question


18:42 ? my.unisa.ac.za l TelkomSA 3G 100% CO51511/102/1/2018 Question ld When running the program given, it is supposed to give the output bewlow. However, the propram contains erros that prevent it from compiling andfor running. Correct the program so that it works propery. The output: Please enter 10 integers, positive negative, The numbers you entered are There are 6 evens, whieh ineludes 2 zeros. The number of odd nunbers is The programc sing nanespace std const int LIMIT· 10: int main float counter int number? lat zeros int odds int evens eout

Explanation / Answer

#include <iostream>
using namespace std;

const int LIMIT = 10;
int main() {
   int number, zeros=0, evens=0, odds=0;

   cout << "Please enter "<< LIMIT <<" integers, positives, negatives or zeroes."<< endl;
  
   // cout<<(0/2)<<endl;
   for(int counter = 0; counter < LIMIT; counter++)
   {
       cin >> number;
       switch( number%2 )
       {
           case 0: evens++;
                   if(number == 0)
                       zeros++;
           break;
           case 1:
           case -1:
                   odds++;
       }
   }
  
   cout<<endl;
  
   cout<<"There are "<<evens<<"evens, which include "<<zeros<<" zeroes."<<endl;
  
   cout<<"The number of odds are: "<<odds<<endl;
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote