Puedes seguirnos en

BUSCADOR

Ciencia y tecnología

Difference between If and Switch statements

Many of you may say that there no difference between these two statements but you are wrong. Both of these powerful statements have their pros and cons.

The IF statement can be used to test conditions so that we can alter the flow of a program. In other words: if a specific statement is true, execute this instruction. If not true, execute this instruction.

The switch statement is almost the same as an IF statement. The switch statement can have many conditions. You start the switch statement with a condition. If one of the variables equals the condition, the instructions are executed. It is also possible to add a default. If none of the variable equals the condition the default will be executed.

Both of these statements are useful in different cases, there are task that cannot be performed by IF statements that can be done by switch and vice versa.

Anuncio publicitario

 

Escrito por

Administrador de ENGGDRCAOS. Canal dedicado especialmente a la formación del estudiante que aspira a ser ingeniero. Todos los videos son Ingles. Apasionado del universo Apple, estudiante de Ingeniería y Gamer por vocación.

Publicidad

ARTÍCULOS RELACIONADOS

Ciencia y tecnología

Nuevas novedades con respecto a la nueva actualización del navegador Google Chrome.

Audio

El auge de los asistentes de voz, la consolidación de las conexiones inalámbricas, el sonido Hi-FI o la revolución de los auriculares Noise Cancelling...

Ciencia y tecnología

No ha pasado ni una semana desde que google puso a la venta su nuevo terminal, el Nexus 5 y a los chicos de...

Android

En la red se escuchan nuevos rumores del próximo terminal de Google denominado Moto X. Según estos rumores encontramos en Android Commuty este terminal...