guessing game project

 #include <stdio.h>

#include<stdlib.h>

#include<time.h>


int main() {

    // Write C code here

    int number;

    int guess , counter ;

    srand(time(0));

     number = rand()%100+1;

     counter = 1;

     

    

    

    do{

        printf(" Guess the no : ");

        scanf("%d",&guess);

        

        if(guess>number){

            printf(" lower no please !\n ");

            counter = counter + 1;

        }

        else if(guess<number){

            printf(" higher no please !\n");

            counter = counter + 1;

            

        }

    }

        while(guess!=number);

        printf(" your no of attempts is %d", counter);

    

        

         

    

    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings