Skip to content
Snippets Groups Projects
Commit 72e66311 authored by Pierre Kunzli's avatar Pierre Kunzli
Browse files

exemple nombre secret

parent e6e35836
Branches
No related tags found
No related merge requests found
No preview for this file type
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main(){
int maximum, reponse;
printf("Entrez la borne maximale : ");
scanf("%d", &maximum);
srand(time(NULL));
int secret = rand()%(maximum+1);
printf("Nombre secret : %d\n", secret);
do{
printf("Entrez un nombre entre 0 et %d: ", maximum);
scanf("%d", &reponse);
if(reponse>secret){
printf("Le nombre secret est plus petit\n");
} else if(reponse<secret){
printf("Le nombre secret est plus grand\n");
} else {
printf("Vous avez réussi !\n");
}
}while(reponse != secret);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment