Write a program that checks wether the or not a number given by the user is even
ID: 3723666 • Letter: W
Question
Write a program that checks wether the or not a number given by the user is even or odd.
Please look at image below
Chapter 5 activity Word Mazen Mohamed - File Home Insert Draw DesignLayout References Mailings Review View ACROBAT Tell me what you want to da Share Find a) Replace Select Editing Calibri (Body) - K Normal 1No Spac.. Hoading 1 Heading 2Title Paste Clipboard Font Paragraph Styles Navigation ven or odd Description Search ducurnernl Headings Pages Results Create an interactive outline of your Write up a program that checks whether.or not a number given by the user is even or odd. The program first asks how many numbers the user would like to check. Afterwards, the program will check that many numbers, telling the user whether each is even or odd. Before the program ends, it will output all the numbers entered along with how many even and odd numbers were input. Example run It's a great way to keep track of where you are or quickly move your content around. How many numbers do you want to check? To get started, go to the Home tab and apply Hoading styles to the headings in your Input number 1 20 Even Input number 2 13 Odd Input number 3 Even 20 13 10 You entered 2 even numbers and 1 odd number Page 1 of 2 344 words 4:41 AMExplanation / Answer
#include <iostream>
using namespace std;
int main() {
cout<<"How many numbers you want to check ?"<<endl;
int n;
cin>>n;
int i=1,inputNumber,noOfOddNumbers,noOfEvenNumbers;
// Variables to store the no of Odd and Even numbers
noOfOddNumbers=0;
noOfEvenNumbers=0;
while(i<=n)
{
cout<<"Input number "<<i<<endl;
cin>>inputNumber;
if(inputNumber%2==0)
{
cout<<"Even"<<endl;
noOfEvenNumbers++;
}
else
{
cout<<"Odd"<<endl;
noOfOddNumbers++;
}
i++;
}
cout<<"You entered " <<noOfOddNumbers<<" Odd numbers and "<<noOfEvenNumbers<<" Even numbers";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.