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

Username:   Password: 
 RegisterRegister   
 Procedure Subprogram Help 2
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SucreTeen123




PostPosted: Mon Apr 09, 2012 6:30 pm   Post subject: Procedure Subprogram Help 2

Anyways I am horrible at Turing and I really need some help! So whoever is out there help!!!!!!!

Question: Write and test a procedure subprogram called swap for swapping the values between two string variables given as parameters of the procedure.


Thank you!
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Tue Apr 10, 2012 8:47 am   Post subject: RE:Procedure Subprogram Help 2

first off, you'll need something like this:

Turing:

proc swap (var a, b : string)

end swap


Now what you've done is created parameters that will change the variable you used. for instance:
Turing:

proc add_5 (var x : int)
     x += 5
end add_5

var num : int

add_5 (num)


Now if you put num, it will be five. If you define your parameter as a variable, it makes it mutible, so it will change it on the outside. Without var, it turns them into constants within that procedure.

So now that you know this, you have a simple task. Find a way to assign a and b's values to eachother
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: