Search code examples
programming-languagesprocessing

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");}
 }

Solution

  • 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.