whats wrong with this?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
recci
Forum Commoner
Posts: 42
Joined: Tue Jul 29, 2008 10:01 pm

whats wrong with this?

Post by recci »

This is just generic code and has 5 things wrong with it. What are ?

Code: Select all

 
var a = 5;
var b = 10;
 
for(i  == 0; 1 < 10; i++)
{
    print(i + a):
)
 
var c = (a*2) - 10;
var d = b / c;
 
print(d);
 
So far Iv spotted :

1. the missing }
2. the : instead of ;
3. i == 0 should be i = 0
4. it should be i < 10
5. unsure?

does that look correct so far?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: whats wrong with this?

Post by onion2k »

var c = (a*2)-10 is going to give you a value of 0 ... which means var d = b / c will result in a divide by zero error.
recci
Forum Commoner
Posts: 42
Joined: Tue Jul 29, 2008 10:01 pm

Re: whats wrong with this?

Post by recci »

yeah that's what I thought
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: whats wrong with this?

Post by pickle »

Don't get us to do your homework.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply