24.12.19

Generating random numbers program in c

#include<stdio.h>

void main()
{

int i,r;

randomize();

for(i=1;i<=10;i++)
{

r=random(100)

printf("%d\t",r);
}

}

OUTPUT:

82 86 72 23 45 48 88 85 48 21



NOTE:

a)  random() takes a number and returns a random number in the range 0 to one less than the given                         number.
b)  randomize() intializes the random number generator with a random value.

No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...