Created
October 11, 2015 02:05
-
-
Save rg3915/2bd785e225330a879c95 to your computer and use it in GitHub Desktop.
Do While example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exemplo de Do While. | |
// Executa a ação, depois pergunta. | |
// Verifica se um número é zero, depois se é par ou impar. | |
int n; | |
do { | |
scanf ("%d", &n); | |
if (n!=0) { | |
if (n%2==0) printf ("par"); | |
else printf ("impar"); | |
} | |
while (n!=0); | |
// Exemplo de While. | |
// Pergunta, depois executa a ação. | |
int n | |
scanf ("%d", &n); | |
while (n!=0) | |
{ | |
if (n%2==0) | |
printf ("par"); | |
else | |
printf ("impar"); | |
scanf ("%d", &n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment