Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Bhasvic Computer Science Chapter 1 - 7a

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    srand(time(NULL));
    
    int randNum = rand()%100,userNum=0;
    
    printf("Guess the hidden number between 0 and 99:");
    scanf("%d",&userNum);
    
    if(userNum == randNum)
    {
        printf("Congratulations! You guessed correctly!");
    }
    else
    {
        printf("Sorry... Wrong answer\n");
        printf("Better luck next time\n");
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.