delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/15/18:20:18

From: ab837 AT sfn DOT saskatoon DOT sk DOT ca (James Edwin Cooper)
Newsgroups: comp.os.msdos.djgpp
Subject: Why doesn't this work (correct, running code)
Date: 15 Jul 1997 05:32:52 GMT
Organization: Saskatoon Free-Net
Lines: 37
Message-ID: <5qf224$6m0$1@missing.link.ca>
NNTP-Posting-Host: broadway.sfn.saskatoon.sk.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Sorry, me again! Anyway, I just made this program, changed it until there 
weren't any DAMN errors, and now it doesn't work! It is a SUPER fast SIN 
calculator (integer values only). The problem is, no matter WHAT number 
you type in, it always pumps out 0.000000. Any reason?

*** WARNING: DJGPP V1 CODE START ***
#include "stdio.h"
#include "math.h"

main()
{ 
 float answer,sintable[360];
 int i,value;
 char number[3];
 printf("Welcome to the SUPER HackEd Sin Number Calculator!\n");
 printf("We are computing your Sin Tables now!\n\n");
 printf("Progress: ");
 for(i=0;i<360;i++)
 {
  sintable[i]=sin(i);
  printf(".");
 }
 printf(" done!");
 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
 printf("Please enter an integer number to be calculated : ");
 gets(number);
 value=atoi(number);
 answer=sintable[value];
 printf("\nThe answer is %f.\n\n");
}
*** WARNING: DJGPP V1 CODE END ***

Sorry if this doesn't look perfect or run fast, it was a 15 minute hack 
by a newbie. Anyway, If this should work, then can you give me hints? 
Otherwise, a simple fix would be nice! Thanks in advance :)
-hacked AT iname DOT com

- Raw text -


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