Tuesday, July 8, 2014

Random number generation using C

#include<stdio.h>
int main()
{
int range, random_number;
printf("Enter range 1 - ? :");
scanf("%d",&range);
random_number = rand(range);
printf("%d\n",random_number);
}
int rand(int range)
{
int temp = (int)&temp;
int random_number = temp % range;
temp = (int)NULL;
if(random_number<0)
random_number = random_number * -1;
return random_number;
}

No comments:

Post a Comment

UA-39217154-2