Jump to content


A. Coelho

Recommended Posts

Podes usar o  switch.

switch (variável)
  case valor1 : expressão; break;
  case valor2 : expressão; break;
  default: expressão;


#include <stdio.h>

int idade;

int main(void)
  printf("Qual a sua dezena de idade (0,10,...)?");
  switch (idade)
    case 0 : printf("Crianca"); break;
    case 10 : printf("Adolescente"); break;
    case 20 : printf("Jovem"); break;
    case 30 : printf("Adulto"); break;
    case 40 : printf("Coroa"); break;
    default : printf("Aposentado");
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.