Author |
Message |
nastynika
|
Posted: Tue Feb 12, 2008 9:57 am Post subject: array |
|
|
started a gr 12 comp ssci class but cant remember how to do most of it can u help me with my code please
var marks : array 1 .. 10 of int
var maximum : int := 0
for i : 1 .. 10
get marks (i)
cls
maximum := marks (i)
put marks (i) ..
end for
put "Maximum = ", Maximum |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Zampano
|
Posted: Tue Feb 12, 2008 11:23 am Post subject: Re: array |
|
|
I guess you want to print the entire array. You don't need the ellipsis points. Of course, if you want to make the aximum the actual highest number, you should check first if it is with an if statement. |
|
|
|
|
|
nastynika
|
Posted: Wed Feb 13, 2008 9:02 am Post subject: Re: array |
|
|
so how do i do that i am trying to have ten marks placed on one line after they are entered then have the maximum mark appear underneath |
|
|
|
|
|
Tony
|
Posted: Wed Feb 13, 2008 9:10 am Post subject: RE:array |
|
|
code: |
if marks(i) > marks(i + 1) then
put marks(i), " is greater than ", marks(i + 1)
end if
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
nastynika
|
Posted: Wed Feb 13, 2008 9:15 am Post subject: Re: array |
|
|
thank you so much Tony |
|
|
|
|
|
Bored
|
Posted: Wed Feb 13, 2008 3:34 pm Post subject: Re: array |
|
|
Well if you need to find a maximum you can also use the max command
Turing: | var a := 8
var b := 54
var maximum : int
put max (10, 25) %Outputs 25
put max (a,b ) %outputs 54
put max (b, 100) %outputs 100
maximum := max (86, 78)
put maximum %outputs 86
|
|
|
|
|
|
|
nastynika
|
Posted: Thu Feb 14, 2008 9:03 am Post subject: Re: array |
|
|
thanx for the help |
|
|
|
|
|
|