# using int beetwin 2 numbers

hello

can we write this :

int freq0 >= 1100 && <= 1150 ?

i want to declare frequency0 beetwin two value

thanks

An int variable can, at any one time, store a single value.
No, you cannot store a range.

thanks

how we can do to say the programm that the frequency is beetwin two value ? like an int

``````if (freq >= 1100 && freq <= 1150)
``````

i want to declare in the top of my programm with , behind the int

Tell us what you want to do, not how you imagine it will be implemented

void loop()
{
pulseHigh = pulseIn(pulsePin, HIGH);
pulseLow = pulseIn(pulsePin, LOW);
pulseTotal = pulseHigh + pulseLow; // Time period of the pulse in microseconds
frequency = 1000000 / pulseTotal; // Frequency in Hertz (Hz)

String sensorVal = String(frequency); // Read the value of the sensor on A0
sensorVal.toCharArray(sensorPrintout, 10); //convert the reading to a char array

if (frequency >= 1100 && frequency <= 1150)
{
Serial.println(frequency);

i want to transform : if (frequency >= 1100 && frequency <= 1150) on : if frequency = freq0
Serial.println(frequency);

thanks

You can't simply invent your own syntax - the C language doesn't allow it.

ok thanks for all

You can't declare that the frequency fits within a range. If it somehow went outside that range then you would want something to happen right? Like maybe print out an error message or take some other corrective action?

If you declared this limit then how do you tell it what to do outside the range? It can't just stop your whole program and wait until it's fixed - the program is stopped so it can't fix anything.

YOU have to write the code to take an action if the number is outside your desired range. If it's a number typed in by a person, you might print an error message like "Frequency cannot be greater than 11500, please re-enter the frequency..." If it's something coming from another input, then you have to write code to allow for that input giving you an unexpected number.

kaiss:
i want to declare in the top of my programm with , behind the int

Just create some variables

``````int maxFreq = 1150;
int minFreq = 1000;
``````

and then use this style to check the frequency

``````if (freq >= minFreq && freq <= maxFreq)
``````

...R

kaiss:
thanks

how we can do to say the programm that the frequency is beetwin two value ? like an int

You cannot declare range types. You can only do explicit runtime checks.