-5

if i want to select a particular no. like if from 1-100 randomly i want to select 1 no. . Is there any way .pleae help in sending the coding i am not from computer background. i'll be thankful to you in advance

- (int)randomNumber
{
int arr[100];
return arr[rand()%100];
}
  • You should've Googled first, you would've found this: http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c – kviiri Jul 31 '14 at 06:03
  • What is the problem with the current code, you should first initialise the array element – Revinder Jul 31 '14 at 06:09

2 Answers2

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

int main()
{
        int c, n;

        printf("Generate a  random numbers in between [1,100]\n");
        srand(time(NULL));
        n = rand()%100 + 1;
        printf("%d\n", n);

        return 0;
}
0

i made a small program and here is the code snippet , i hope it helps.

 randomize(); // random number generation
 v1=random(100);
 delay(2000);
 printf("\n Computer chose ");
 printf("%d",v1);