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?
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.
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;
}
#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;
}
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?
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?
Guru said:
1 decade ago
But one thing!
As all answer suggest it "returns".
Actually randomize() returns nothing, it only initialize with random value.
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.
This question is invalid for the reason stated.
Randomize doesn't return a random number generator.
Vishu said:
9 years ago
Yeah, the output is an error: too many arguments to a fun 'random'.
Anyone explains me.
Anyone explains me.
Ahmed said:
9 years ago
OUTPUT.
Error: too many arguments to function 'random'.
Please help me.
Error: too many arguments to function 'random'.
Please help me.
Pankaj kumar said:
2 decades ago
This compiler is great.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers