Hi so for this program it says:
1)Allow the user only three chances to enter the correct number.
2)The program should stop if the user doesn't enter the correct value after the third try
3) The program should stop if the user guess correctly(and is less than 3 tries)

here is the code:
Code:
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#include<time.h>


// Declaration Section
int num;
int guess;


void pauseProgram()
{
     printf("\nPress any key to continue...");
     getchar();
     }
     
     // Function Title
     void title(char*programTitle)
     {
          int len=strlen(programTitle);
          system("cls");
          printf("\n");
          for(int i=1;i<40-len/2;i++) printf("");
          printf("%s\n",programTitle);
          }
          
          // User lnput
          void userlnput()
          {
               title("Random Number");
               printf("\nEnter a number between 1 and 100:");
               scanf("%d",&guess);
               getchar();
               }
               
               //Funcion displayRand
               void displayRand()
               {
                    /* The following 2 lines are needed for generating
                    dufferent random numbers for each execution.
                    Simple "srand()" seed: just use "time()"
                    */
                    unsigned int iseed= (unsigned int)time(NULL);
                    srand(iseed);
                    
                    num= rand()%100;
                    num= num+1;
                    title("Random Number");
                    if(guess>num)
                    printf("\nCome down!\n");
                    else if(guess<num)
                    printf("\nWay down there?\n");
                    else
                    printf("\nRight on!\n");
                    
                    pauseProgram();
                    }
                    
                    // Main Program
                    int main()
                    {
                        do
                        {
                              userlnput();
                              displayRand();
                              if(num==guess)
                              {
                                            break;
                                            }
                                            }while(1);
                                            }