LANGUAGE: ARDUINO WITH ARDUINO... Build a program that allows three data to be r
ID: 3742056 • Letter: L
Question
LANGUAGE: ARDUINO WITH ARDUINO... Build a program that allows three data to be read through the serial port: a range specified by the lower limit and the upper limit and a number N that is within the range. He program determines all numbers in the range that are multiples of N, for example: Lower limit: 1 Upper limit: 10 N: 3 The program should indicate: The multiples of 3 are: 3 6 9 Points to consider: a) The program should include the function called bool multiples (int x, int N) that calculates if x is a multiple of N, if it is true, otherwise returns false. b) Call the sketch MultiploesN
Explanation / Answer
here's your code ;)
int bool_multiples(int m,int n)
{
for(int i=m;i<=n;i++)
{
if(i%a==0)
{
serial.println(i);
}
}
}
void setup()
{
}
void loop()
{int m,n,i,a;
serial.print("enter the lower number:");
m=serial.read();
serial.print("enter the upper number:");
n=serial.read();
serial.print("enter the number whose multiple you want to print: ")
a=serial.read();
if(m<=n)
{
for(i=m;i<=n;i++)
{
serial.println(i);
}
}
bool_multiples(int m,int n)
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.