Skip to content

Instantly share code, notes, and snippets.

@rg3915
Created October 11, 2015 02:05
Show Gist options
  • Save rg3915/2bd785e225330a879c95 to your computer and use it in GitHub Desktop.
Save rg3915/2bd785e225330a879c95 to your computer and use it in GitHub Desktop.
Do While example
// 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