C Programming - Library Functions - Discussion

Discussion Forum : Library Functions - General Questions (Q.No. 8)
8.
What will the function randomize() do in Turbo C under DOS?
returns a random number.
returns a random number generator in the specified range.
returns a random number generator with a random value based on time.
return a random number with a given seed value.
Answer: Option
Explanation:

The randomize() function initializes the random number generator with a random value based on time. You can try the sample program given below in Turbo-C, it may not work as expected in other compilers.

/* Prints a random number in the range 0 to 99 */

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

int main(void)
{
    randomize();
    printf("Random number in the 0-99 range: %d\n", random (100));
    return 0;
}

Discussion:
8 comments Page 1 of 1.

Pankaj kumar said:   2 decades ago
This compiler is great.

Sachin said:   1 decade ago
When we are executing a C program sometime we will get Segmentation fault or core dumped as an error, then Why that error will occur in a program what should be made to clear that error?

Guru said:   1 decade ago
But one thing!

As all answer suggest it "returns".

Actually randomize() returns nothing, it only initialize with random value.

Rover said:   1 decade ago
Thank you Guru.

This question is invalid for the reason stated.

Randomize doesn't return a random number generator.

Himanshu said:   1 decade ago
This program shows error in Dev C and other online compilers like codepad, codeonline and ideone. I didn't get this. Someone can help?

Ahmed said:   9 years ago
OUTPUT.

Error: too many arguments to function 'random'.

Please help me.

Vishu said:   9 years ago
Yeah, the output is an error: too many arguments to a fun 'random'.

Anyone explains me.

Bikash said:   6 years ago
According to me, it is;

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
srand(time(0));
for(int i=0;i<5;i++)
printf("Random number range: %d\n",rand());
return 0;
}

Post your comments here:

Your comments will be displayed after verification.