Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!crackers!m2c!wpi.WPI.EDU!kamal From: kamal@wpi.WPI.EDU (Kamal Z Zamli) Newsgroups: comp.lang.pascal Subject: Re: Help Me!!! What's wrong with this simple problem? Message-ID: <1990Nov28.191625.12509@wpi.WPI.EDU> Date: 28 Nov 90 19:16:25 GMT References: <527@shum.UUCP> <19956@oolong.la.locus.com> <28893@shamash.cdc.com> Organization: Worcester Polytechnic Institute Lines: 24 In article <28893@shamash.cdc.com> mpe@shamash.UUCP (Mike Ebsen) writes: >What's wrong with this problem in Turbo Pascal 5.0... > > Program test; > var > i : integer; > j : word; > begin > j:=3; > i:=j-10; > writeln(j,' ',i); > end. > >My compiler tells me that the assignment of -7 into i (an integer) >is an error. The reason that Turbo Pascal gives you an error is that you define j as of type word. if you declare a var of type word you must make sure that its value will never go negative. In other word 0