Active Topics

 


Reply
Thread Tools
Posts: 562 | Thanked: 123 times | Joined on Nov 2009 @ Daly City
#1
guess here is the best place to ask this question since a lot of people knows how to do programming.. so I am taking my 1st programming class.. and i got a small problem.. idk how to write peudocode..

here's the problem..

The variable X starts with the value 0.
The variable Y starts with the value 5.
Add 1 to X.
Add 1 to Y.
Add X and Y, and store the result in Y.
Display the value in Y on the screen.


now I need to write it in psuedocode and also the output.. anyone willing to explain it and give me some examples..
__________________
N900(40GB) PR1.3|NITDroid|Power40|MeeGo @1GHz
Nokia N9(64GB)Black|PR1.1
ASUS G73JH| i7-720QM | 1.6-2.8GHz | WIN 7 Pro | ATI 5870 1GB DDR5 | 8GB RAM DDR3 1333MHz | 80GB X-25 G2 SSD+500 GB HDD | 1920x1080 | RAZER MAMBA | ALIENWARE BACKPACK(WTF?)| Intel 6200 WIFI|

Last edited by chase15; 2011-07-09 at 01:51.
 
Posts: 69 | Thanked: 55 times | Joined on Nov 2009
#2
IMHO this is already pseudocode.

The variable X starts with the value 0.
The variable Y starts with the value 5.
Add 1 to X.
Add 1 to Y.
Add X and Y, and store the result in Y.
Display the value in Y on the screen.

You can write it also as:

x=0
y=5
x=x+1
y=y+1
y=x+y
print y
 
Posts: 35 | Thanked: 22 times | Joined on Jul 2010 @ Moscow
#3
Originally Posted by farmatito View Post
You can write it also as:

x=0
y=5
x=x+1
y=y+1
y=x+y
print y
This is not a pseudocode! This is a python code


@chase15
Well, there's not much to explain, everything pretty obvious:
Code:
x=0          # Here you define that x is equal to 0
y=5          # Same with y, just value is different
x=x+1        # You assign x result of x+1 (which is 0+1), x=1
y=y+1        # Same with y (5+1), y will be 6
y=x+y        # Assign y result of x+y (1+6), y=7
print y      # Guess what that does :)
Output is
Code:
7
Note, that in some (well, most) languages you have to declare (and initialize) variable before you can use it, so it will be like this:
Code:
var x=0
var y=5
x=x+1
...
 
Posts: 562 | Thanked: 123 times | Joined on Nov 2009 @ Daly City
#4
well pretty much.. i did the code type one.. and come up with the same output.. i was asked to rewrite it on "assignment" way.. which im not sure what it is..
__________________
N900(40GB) PR1.3|NITDroid|Power40|MeeGo @1GHz
Nokia N9(64GB)Black|PR1.1
ASUS G73JH| i7-720QM | 1.6-2.8GHz | WIN 7 Pro | ATI 5870 1GB DDR5 | 8GB RAM DDR3 1333MHz | 80GB X-25 G2 SSD+500 GB HDD | 1920x1080 | RAZER MAMBA | ALIENWARE BACKPACK(WTF?)| Intel 6200 WIFI|
 
Reply


 
Forum Jump


All times are GMT. The time now is 19:26.