C program in SUN 3/50

Sanjoy Mukherjee mukherje at boc.rutgers.edu
Fri Jan 18 04:09:19 AEST 1991


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 at 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 
--------------------------



More information about the Comp.unix.programmer mailing list