Mail Archives: djgpp/1998/05/10/11:50:40
Jonathan Summers wrote:
> Hopefully this has a simple answer.
>
> How do you right justify using fprint, so that it comes out looking
> like:
>
> 123.45
> 12.34
>
this question is really off-topic. for basic c questions, try
comp.lang.c or comp.lang.c.moderated, and their faq. also, do make a
habit of reading the docs.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define COUNT 10
#define MAX_VALUE 1000.0
int main(void)
{
int i;
double a[COUNT];
srand(time(NULL));
for(i = 0; i < COUNT; i++)
{
a[i] = (double)( MAX_VALUE*(((double) rand())/RAND_MAX) );
printf("%8.2f\n", a[i]);
}
return 0;
}
--
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA
mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/
- Raw text -