Turncoat 300!!

Computer Science Level pending

What will the output of this code when run on the Turbo C compiler?

1
2
3
4
5
6
void main{

    int a = 300 * 300 / 300;
    printf("%d", a);

}

Details

  • The Turbo C compiler uses 16 bit int .
81 Error 900 300

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Afreen Sheikh
Apr 18, 2015

In Turbo C, int is 16 bits wide.

300 * 300 = 90000 (17 bits) = 15F90h

15F90h will be truncated ( 1 bit is lost) into 5F90h (16 bit) = 24464.

If you divide 24464 with 300, you get 81 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...