Daniel Hobbs
Daniel Hobbs

Reputation: 119

Maths in processing language

Ok, so I am a little lost with Processing Programming Language again, so wondering if anyone can help my brain become unblocked?

This is the question - "Write a program which compares two numbers, if one of the numbers is larger than the other then the two numbers are added together and the result is printed in the console window."

So I have got this, but im getting errors on just the 'int' value code which is making me think ive completely misunderstood this?.. possibly misunderstood how the language works :/

Here is my code;

void setup() {
int a = 30
int b = 20

 if (a > b) {printIn("a+b");}
 }

Upvotes: 1

Views: 158

Answers (3)

user1840211
user1840211

Reputation: 11

The l in println(); should be lowercase. There is no need for the quotes around the variables.

This works:

void setup() { int a = 30; int b = 20; if(a > b) {println(a + b); }}

Upvotes: 0

walkytalky
walkytalky

Reputation: 9543

Generally it helps if you post what errors you're getting. However, in this case you have a very basic syntax problem: you need to terminate your statements with semicolons - including the assignments. Eg: int a = 30;

Oh, and it's println (with a lowercase L) not printIn. And, as noted by logoff, you're doing the sum inside a quoted string, which will just print as a literal.

Upvotes: 1

Steef Burghouts
Steef Burghouts

Reputation: 3

If I understad it correctly you have to declare the variables outside the setup() method. Intialization can be done inside the method.

Upvotes: 0

Related Questions