Question

Write a program that will let the user enter the number and then it will output...

Write a program that will let the user enter the number and then it will output "even" if the number is even, and "odd" if the number is odd. Example output 1: Enter the number: 369 The number is odd. Example output 2: Enter the number: 866 The number is even. (Must be done in Code::Blocks C++)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Open codeblocks

then go to file->new->empty file

write this code there

#include<bits/stdc++.h>
using namespace std;
int main()
{
//prompt the user to enter the number
cout<<"Enter the number:";
int n;
cin>>n;
//if n leaves remainder with 2 then n is odd
if(n%2)
{
cout<<"The number is odd"<<endl;
}
//else n is even
else
{
cout<<"The number is even"<<endl;
}
}
save the file with .cpp extension

press f9 to compile and run

Add a comment
Know the answer?
Add Answer to:
Write a program that will let the user enter the number and then it will output...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT