#include <stdio.h> #include<stdlib.h> #include<time.h> int main() { int number , nguess=1 , guess; srand(time(0)); number = rand()%100+1; // printf("the number is %d" , number); do{ printf("guess the number between 1-100 %d\n" , guess); scanf("%d" , &guess); if(guess<number){ printf("enter higher number\n"); } else if(guess>number){ printf("enter lower number\n"); } else { printf("you guessed the number in %d attempts\n" , nguess); } nguess++; } while(guess!=number); //code return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter