i wrote a c++ prgram
i have aproblem abt the output;
the program is as

#include<conio.h>
#include<iostream.h>
void main()
{
int i=1;
i=400*400/400;
cout<<i;
getch();
}

the output of this is =72
can somebody tell me that
is this any type of garbage value???????????

400*400 is 160000

This is somewhat larger than the 16 bits (max 32767) that your ancient TurboC compiler can manage.

UPGRADE!

just look at the precedence table multiplication has higher precedence than division when control reaches at i=400*400/400; product happens prior than division but 400*400 should not be stored just in two bytes.
you can use unsigned int for desired result

commented: multiplication does NOT have higher precedence than division. they are the same. Get it right, foo. -2

you can use unsigned int for desired result

No you can't. Not on a 16-bits compiler anyway, read the post above your own.

@OP: time to update to something from the last decade. Like code::blocks with the mingw compiler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.