LÓGICA DA PROGRAMAÇÃO

LAÇOS DE REPETIÇÃO  

Postado por SOL

Utilizamos este tipo de estrutura quando desejamos repetir a execução de um trecho do programa um número finito de vezes:

Exemplo 1:



I=0

NO JAVASCRIPT:

VAR I;

FOR (I=0; I<10;I=I+1) {
alert (I);
}

COMO ABAIXO:

CRIE UM PROGRAMA QUE EXIBA NA TELA OS NºS DE 01 A 10:
<html>
<head>
<title> LACOS DE REPETICAO 1 </title>
</head>
<body>
<script type = "Text/Javascript">

//CRIE UM PROGRAMA QUE EXIBA NA TELA OS NºS DE 01 A 09

var I;

for (I=0;I<10;I=I+1){ document.write (I +"
");
}

</script>
</body>
</html>

VISUALIZAÇÃO:

This entry was posted on segunda-feira, abril 07, 2008 and is filed under . You can leave a response and follow any responses to this entry through the Assinar: Postar comentários (Atom) .

0 comentários