Article View: ru.qa
Article #1C program in SUN 3/50
From: Sanjoy Mukherjee
Date: Thu, 17 Jan 1991 17:09
Date: Thu, 17 Jan 1991 17:09
32 lines
1369 bytes
1369 bytes
hi,
I have been bumped by the following piece of code.
The last argument of the printf statement is giving wrong answer.
Any pointers ????
Please e-mail your reply, because I donot read these newsgroups often
thanx in advance
-- Sanjoy Mukherjee (mukherje@paul.rutgers.edu)
--------------------------------------------------------------------------
#include <math.h>
#include <stdio.h>
int a,b,c,d,g,e;
main(argc,argv)
int argc;
char *argv[];
{
a = atoi(argv[1]); b= atoi(argv[2]); c=atoi(argv[3]);
d = ceil(((double)a)/((double)b));
g = a*b;
printf("\n%d %d %d %d %d %d %d \n",a,b,c,d,d*c,g,ceil(((double)a)/((double)b))+g);
}
---------------------------------------------------
Compiling command : cc test.c -lm
----------------------------------
Run : a.out 1 2 3
------------------------
Output: 1 2 3 1 3 2 1074266112
--------------------------
Technical Details
Message-ID:
<Jan.17.12.09.14.1991.1160@boc.rutgers.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!rutgers!elbereth.rutgers.edu!remus.rutgers.edu!paul.rutgers.edu!boc.rutgers.edu!mukherjeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!rutgers!elbereth.rutgers.edu!remus.rutgers.edu!paul.rutgers.edu!boc.rutgers.edu!mukherje From: mukherje@boc.rutgers.edu (Sanjoy Mukherjee) Newsgroups: ru.qa,comp.unix.programmer,comp.unix.large,comp.bugs.misc Subject: C program in SUN 3/50 Keywords: C Unix SUN 3/50 Message-ID: <Jan.17.12.09.14.1991.1160@boc.rutgers.edu> Date: 17 Jan 91 17:09:19 GMT Followup-To: ru.qa Organization: Rutgers Univ., New Brunswick, N.J. Lines: 32