Computer Science, asked by suzzain4, 8 months ago

write a program to generate a random number between 1 to 50 by using C language

Answers

Answered by kumarshikhar597
0

Answer:

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

int main ()

{

 int number, input;

 /* initialize random seed: */

 srand (time(NULL));

 /* Generate a random number: */

 number = rand() % 10 + 1;

 do {

   printf ("\nGuess the number (1 to 10): ");

   scanf ("%d",&input);

   if (number > input)

    printf ("The number is higher\n");

  } while (number!=input);

 printf ("That is correct!\n\n");

 return 0;

}

Explanation:

Similar questions