TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Roy McNeill
from: Paul Edwards
date: 1996-08-30 22:10:14
subject: reciprocal

The code being reposted reminded me to try again, which I did, and this
time it worked.  Is your code public domain?  BFN.  Paul.

/* Written by Roy McNeill */
/* Copyright status unknown */
/* Modified by Paul Edwards */
/* Set i to the number you want the reciprocal of */

#define PLACES 501

#include 
#include 
#include 

int main(void)
{
    long i, j, top;
    int place;
    char ans[PLACES + 1], buf[40];

    i = 300;
    top = 1;
    for (place = 0; place < PLACES; place++)
    {
        j = top / i;            /* divide */
        ltoa(j, buf, 10);       /* convert to string. Answer should be 1
                                   digit. */
        ans[place] = *buf;      /* add digit to big answer */
        top = top - j * i;      /* get remainder */
        top *= 10;              /* shift one decimal place */
    }
    ans[PLACES] = '\0';
    printf("ans is %s\n", ans);
    return 0;
}
@EOT:

---
* Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.