How can I generate floating-point random numbers?



How can I generate floating-point random numbers?..

Answer / Nibha Kumari

To generate floating-point random numbers in C, you can use the rand() function with a proper seed value and divide it by RAND_MAX to get a float between 0.0 and 1.0. Alternatively, you can use the more modern random number generation functions such as random() or drand48().

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

A MobileNumber is a VIP number if it satisfy the following conditions. The operator should be Vodafone. Atleast one 0 (Zero) should be exist in mobile number. The number should not end with 8. The single digit sum of all the digits in the number should be equal to 9. For example if the number is 9876543210, the sum is 9+8+7+...+1+0 = 45. Sum of 4+5 = 9. Write a method: private boolean isVIPMobileNumber(String mobileNum, String operator) mobileNum phone number operator mobile operator as bsnl, Vodafone

1 Answers  


What does *p++ do? What does it point to?

1 Answers  


What is Full Form of C and Why We use C

23 Answers  


is it possible to change the default calling convention in c ?

1 Answers   Aptech,


write an algorithm and a program to count the number of elements in a circularly singly linked list

1 Answers   Ignou,


Compare interpreters and compilers.

1 Answers  


identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5;

8 Answers   TCS,


Are there namespaces in c?

1 Answers  


Meaning of () in c

1 Answers  


Is main() function predfined or userdefined?

11 Answers  


Is null always equal to 0(zero)?

1 Answers  


write a c code "if you give a any decimal number then print that number in english alphabet"? ex: i/p: 552 o/p: five hundred fifty two ...

1 Answers   Philips,


Categories