delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/10/11:50:40

From: "A. Sinan Unur" <Sinan DOT Unur AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Justification
Date: Sun, 10 May 1998 11:30:59 -0400
Organization: Cornell University (http://www.cornell.edu/)
Lines: 46
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <3555C833.8EC76B7A@cornell.edu>
References: <3554CEB2 DOT 60C442D2 AT beverly-hills-ca DOT com>
NNTP-Posting-Host: cu-dialup-1606.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019