C Program – Random Float number Generator

by Nideesh C on May 9, 2011 · 0 comments

in C Programming




//Downloaded From theonlinetutorials.com
#include"stdio.h"
#include"stdlib.h"
#include"time.h"
#include"limits.h"
float Frand(int n)
{
float m;
m=(float)(rand())/RAND_MAX;
m+=rand()%n;
return m;
}
float Frand1(int n)
{
float m,temp;
temp=(float)rand()/RAND_MAX;
m=n*temp;
return m;
}
int main()
{
int  n,i;
printf("Enter a int no to which you want to generate an random float no");
scanf("%d",&n);
printf("This program will be tested 10 times");
for(i=0;i<10;i++)
{
randomize();
printf("\n%f",Frand1(n));
printf("\t%f",Frand(n));
system("pause");
}
return 0;
}



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program – Implement the midpoint circle drawing algorithm
  2. C program – Shortest Job Next
  3. C program to reverse a given integer number and check whether it is a palindrome. Output the given numbers with suitable message
  4. C program to generate and print prime numbers in a given range. Also print the number of prime numbers
  5. C program to accept N numbers sorted in ascending order and to search for a given number using binary search. Report success or failure in the form of suitable messages

Leave a Comment

Previous post:

Next post: