Q1. Write the c++ implementation for the following pseudocode
*Get number
*check=number%2
*if check =0 display "its even number "
*else display "its an even number "
Q2. write the c++ conditional statements for the following situations
a.if the data is between 25 to 50 or the data is more than 100
b.if the data character is not A or a
c. if data is equal or less than zero but more than -250
It's obviously a homework problem. Try writing the code out and if you have problems/questions, post them and we'll see if we can push you in the right direction, but do not expect anyone here to write this for you. It's not very complicated, just give it a shot.
#include <iostream>
usingnamespace std;
int main()
{
int number;
cin >> number;
if ( This is where number%2 is done)
{
// This is where you output text if the number is even
}
else
{
// This is where you output text if the number is odd
}
return 0;
}
That should give you all you need and basically solves your question. All you need to do is fill in the blanks.
#include <iostream>
usingnamespace std;
int main()
{
int num;
cout<<"Enter a number: ";
cin>>num;
if(num%2==0)
{
cout<<"It's an even number";
}
else
{
cout<<"Its an odd number ";
}
cout<<endl;
return 0;
}
This is such a basic program. I am not sure why you are having trouble writing it after the hint was given above by some other members. Spend some time on C++ otherwise you will be stuck when you study new concepts like Pointers, Functions, Arrays etc..I think you should be able to solve 2nd problem now.
If you tried, perhaps you could show some evidence of that. Most people around here would much rather tell you what you're doing wrong than outright supply you the answer.
Well your answer for question one is wrong to. main need to be int main() not void main(). Main always returns a integer so that is why it need to be int. If you compiler compiles with void main() I would highly suggest switching to a new compiler or updateding (I'm assuming your probably using Bloodshed Dev C++, if thats the case upgrade to the new Orwell Dev C++ which has just been updated)
Also I gave you the outline for question 2 so you should be able to do it if you did a little research and not just look for people to give you the answers.