[comp.unix.programmer] C Program in SUN 3/50

mukherje@boc.rutgers.edu (Sanjoy Mukherjee) (01/18/91)

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

mukherje@monkees.rutgers.edu (Sanjoy Mukherjee) (01/18/91)

 thanx, for all your replies to my original query.

I took the definition of ceiling function literally and didnot check
the manual properly. Sorry for the oversight.

sanjoy