Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 array
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nastynika




PostPosted: 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
Sponsor
sponsor
Zampano




PostPosted: 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




PostPosted: 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




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
nastynika




PostPosted: Wed Feb 13, 2008 9:15 am   Post subject: Re: array

thank you so much Tony
Bored




PostPosted: 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




PostPosted: Thu Feb 14, 2008 9:03 am   Post subject: Re: array

thanx for the help
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: