If within If

I am trying to make a noise detector. I use two regular electronic push button. If button A is pressed one code will be run. If button B is pressed, another different code will be run. Inside both of this a and b code there is another if statement respectively.

I wanted to create an if statement based on push button input for the first choice and inside this A and B code there will be another if statement based on the sensor input. Could this work?

How are your buttons and sensor connected? Post your code, like this:
HowToPostCode

akubas86:
I am trying to make a noise detector. I use two regular electronic push button. If button A is pressed one code will be run. If button B is pressed, another different code will be run. Inside both of this a and b code there is another if statement respectively.

I wanted to create an if statement based on push button input for the first choice and inside this A and B code there will be another if statement based on the sensor input. Could this work?

Sure! That is just another way of writing "If x is true AND y is true, do something".

Paul

You can cascade IF statements - something like

if buttonA is pressed {
    if something happens {
       do stuff
    }
    else {
       do other stuff
    }
}

if buttonB is pressed {
   // etc

This style can often make the relationships more obvious.

You might also want to consider the other order - something like this

if something happens {
   if buttonA is pressed {
      do stuff
   }
   else if buttonB is pressed {
      do xyz
   }
}
else {
 // etc

...R