C Project – Number Guessing Game

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Project for Guess randmom number
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define clrscr() system("cls")
int main()
{
     clrscr();
     int me,you,i=1,count=10;
     srand(time(NULL));
     me=rand()%100;
    
     while(i<=10)
    { 
        printf("\n Enter a number : %d chance left",count);
        scanf("%d",&you);
      if(me==you)
      {
        printf(" ************ Great You win the game*************");
         break;
      }   
      if(you>me)
      printf("\n Your number is grater than my number: ");
      else
      printf("\n Your number is less than my number: ");
      count--;
       i++;  
    }        
   if(count==0) 
    printf("\n Oops you failed to enter correct number Game is over now you loss the game.... ");
    

     return 0 ;
}

 

We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *