Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CABEÇALHO
- Arquivo: LISTA 03 - Exercicio 15.c
- Objetivo: Descubra o numero sorteado atraves de algumas tentativas.
- Autor(a): Ramon Borges
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main()
- {
- int numeroAlvo, numeroUsuario, cont = 0, saida = 0;
- srand(time(NULL));
- numeroAlvo = rand() % 100;
- printf("\n******DESCUBRA O NUMERO******\n");
- do
- {
- printf("\nDigite um numero de 1 a 100: ");
- scanf("%d", &numeroUsuario);
- if(numeroUsuario > numeroAlvo)
- printf("\nTente um numero menor.");
- else if(numeroUsuario < numeroAlvo)
- printf("\nTente um numero maior.");
- else
- {
- printf("\nParabens, voce conseguiu!!!");
- saida = -1;
- }
- cont++;
- }while(saida != -1);
- if(cont == 1)
- printf("\nOTIMO! Voce alcancou a facanha com apenas 1 tentativa!!!\n");
- else if(cont < 7)
- printf("\nBOM! Voce alcancou a facanha com apenas %d tentativas!!!\n",cont);
- else if(cont < 15)
- printf("\nREGULAR! Voce alcancou o numero com %d tentativas!!!\n",cont);
- else
- printf("\nPRECISA MELHORAR! Voce alcancou o numero com %d tentativas!!!\n",cont);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment