//creating functions
int encodeNumber(int number){
//int result = (number+3)*5;
//return result;
return (number+3)*5; //this will give the same result as the code above
}
void printEncodedNumber(int number){ //putting void means that the function doesn't return anything
Serial.println(encodeNumber(number));
}
int number1 = 5;
int number2 = 6;
void setup() {
// put your setup code here, to run once:
//int encodedNumber1 = (number1+3)*5;
//int encodedNUmber2 = (number2+3)*5; //same process here, a bit tedious to have to
//do this every time
Serial.begin(9600);
int encodedNumber1 = encodeNumber(number1);
int encodedNumber2 = encodeNumber(number2);
printEncodedNumber(number1);
}
void loop() {
// put your main code here, to run repeatedly:
}
// global variables can be delcared in any scope
// local variables can only be delcared in the scope they were created in or in nested scopes within that scope.