luishenriique

Sair do programa?

Apr 29th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5.     char opcao;
  6.  
  7.     do{
  8.         printf("\n");
  9.         printf("Deseja sair do programa? [s/n]: ");
  10.         opcao = getchar(); fflush(stdin);
  11.         switch(opcao){
  12.         case 'N':
  13.         case 'n':
  14.             system("cls");
  15.             main();
  16.         case 'S':
  17.         case 's':
  18.             return 0;
  19.         }
  20.         printf("Opcao invalida.\n");
  21.     }while(opcao != 'N' || opcao != 'n' || opcao != 'S' || opcao != 's');
  22. }
Advertisement
Add Comment
Please, Sign In to add comment