Doing multiple arithmetic expressions
in
Programming Questions
•
11 months ago
Ok, so still getting use to the basics with processing, and I am unsure if this is the correct way to do multiple arithmetic expressions with the same data, should I be typing each as its own code, or doing it like this?
here is the question;
here is my code;
3. Write the statements which perform the following arithmetic operations (note: the variable names can be changed).
(i) a=50 b=60 c=43
result1 = a+b+c
result2=a*b
result3 = a/b
here is my code;
- short a = 50;
- short b = 60;
- short c = 43;
- int sum = a+b+c; // Subsection i
- print (sum);
- int sum2 = a*b; // Subsection ii
- print (sum2);
- int sum3 =a/b; // Subsection iii
- print (sum3);
1