Assignment Question!!!!!!

Jan 30, 2013 at 1:07pm
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

stuckeed in these questions!!!!!!!!!!!!!!!

Jan 30, 2013 at 1:18pm
How far did you get, what's the sticking point?

By the way, the first part doesn't make sense:
*if check =0 display "its even number "
*else display "its an even number "

Are there to be no odd numbers?


If you are really stuck, then this might be a good starting point:
http://www.cplusplus.com/doc/tutorial/
Last edited on Jan 30, 2013 at 1:19pm
Jan 30, 2013 at 1:27pm
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 odd number "


typing error !!! can you solve it now !!!!
Jan 30, 2013 at 2:13pm
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.
Jan 30, 2013 at 2:23pm
closed account (3qX21hU5)
Here is some framework for you to start working on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

using namespace 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.
Jan 30, 2013 at 7:22pm
thnx bro wht about for the second question?
Jan 30, 2013 at 7:40pm
closed account (3qX21hU5)
That ones should be easy enough for you to figure out if you can do the first one.

It is three different conditional statements.

1) if (data is between 25 - 50 OR over 250)

2) if (variable is not 'a' OR 'A')

3) I'll let you do this one :)
Jan 30, 2013 at 9:31pm
i tried alot but i still couldn't make it
Jan 30, 2013 at 10:09pm
*Get number
*check=number%2
*if check =0 display "its even number "
*else display "its an even number "

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#include <iostream>
using namespace 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.
Jan 30, 2013 at 10:42pm
i tried alot but i still couldn't make it


http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html

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.
Jan 31, 2013 at 9:53am
#include <iostream>

using namespace std;

void main()
{
int number;
cout<<"Enter the number\n";
cin >> number;

if (number%2==0)
{cout<<"its an even number\n";}
else
{cout<<"its an odd number\n";}
system("pause");
}


this is evidence for question 1 . but im stucked in question no 2
Jan 31, 2013 at 9:57am
question 1 is easy !!!!
i dont know how to do question 2?
Jan 31, 2013 at 12:43pm
closed account (3qX21hU5)
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.
Topic archived. No new replies allowed.