The code fails to generate the values I want, when both trigger pins 2, 3 are high or low. Why? /*aim of the program is to generate 2 different varying frequency from the
same output which is controlled by 2 triggers*/
void setup()
{
    pinMode(2,INPUT); //setting the trigger pins 2,3
    pinMode(3,INPUT);
    pinMode(6,OUTPUT); //output pin
}

void loop()
{
    if(digitalRead(2)==HIGH &amp;&amp; digitalRead(3)==LOW) { //trigger conditions
        infra();
    }
    else if(digitalRead(2)==LOW &amp;&amp; digitalRead(3)==HIGH) {
        red();
    }
    else if((digitalRead(2)==HIGH &amp;&amp; digitalRead(3)==HIGH) || (digitalRead(2)==LOW &amp;&amp; digitalRead(3)==LOW)) {
        Serial.println('help');
    }
}

void infra() //function varies sinosoidaly (working)
{
    float f;

    for(f=16000; f&lt;=20525; f+=4.525) {
        tone(6,f);
    }

    for(f=20525; f&gt;=16000; f=f-4.525) {
        tone(6,f);
    }
}

void red() //function varies sinosoidaly (working)
{
    float p;

    for(p=25000; p&lt;=32071; p+=7.071) {
        tone(6,p);
    }

    for(p=32071; p&gt;=25000; p=p-7.071) {
        tone(6,p);
    }
}
To send anything to serial you need to initialize it first with:

void setup()
{
    Serial.begin(115200);
    //other code
}


And you are using wrong quotes for the string.
They should be double quotes " not single ones '.

Also you could simplify your code, if you removed the third if, since it's just checking the already known state at that point.

You should also read the button state only once, save them into a variable and then just compare those variables.

bool button1_state = digitalRead(2);
bool button2_state = digitalRead(3);
if (button1_state &amp;&amp; !button2_state) {
    infra();
}
else if (!button1_state &amp;&amp; button2_state) {
    red();
}
else {
    Serial.println("help");
}