Subj : Re: Math error ??? doen't make sense! To : borland.public.cpp.borlandcpp From : maeder Date : Fri Jul 02 2004 08:36 am "Stan DeGroff" writes: > I Programmed in Assembly, Fortran, DbaseIV, MS Prof Basic pre-Win for many > years. > This new stuff is mind blowing. So.. I ask for your patient help. > > I am using the Sam's Learning C in 24hr book that came with my new > Bc++ 5.02 compiler. (I need to learn it from ground up.) > Reason for using old software is simple. I need to target 16bit embedded > computer. > > Ch 9 Exercise 3 > ------------------- > > #include > #include > main() While your compiler may accept this, it's not correct. The return value of each function has to be explicitly given, as in: int main() > { > int x,y; > long int z; > > x=7000; > y=12000; > z=x*y; > > printf("x * y == %lu\n",z); Welcome to the world of *printf format string intricacies! %lu tells the printf engine to expect an unsigned long, but you are passing it a (signed!) long. What do you get if you change %lu to %ld (or %li, if you prefer)? If you don't get the expected result, chances are that long int is too small to hold the result of the above multiplication. I don't remember how large a long int was on Borland C++ 5.02 in 16bit programs. What do you get if you do: int main() { printf("%u\n",sizeof(long)); } ? .