Computer Science Canada help quick before tomorrows exam! |
Author: | Ryan [ Thu Jan 23, 2003 8:55 pm ] |
Post subject: | help quick before tomorrows exam! |
Hey, may seem a dumb question but i can't remember if you can have more than one output variable from a procedure. i have to do some review before my exam tomorrow, and the context the question is from is this: Write a turing program to determine if a triangle is really a triangle given the length of it's sides. we just learned about subprograms recently, so i apologize for the question. I think i need to accept several inputs all from one variable then cast them into different variables. if i'm correct, then i believe i need to put more than one variable as the output at the start. procedure Sides (var length : int, var lengths : real) thanls for any help! Ryan |
Author: | Tony [ Thu Jan 23, 2003 9:06 pm ] | ||
Post subject: | |||
procedures don't output variables... thats functions and you can have unlimited number of arguments passed into the procedure... so
A bit of explanation there... this is a function and returns a value... true if its a triangle, false if its not. Those 3 if statments are semplified version of the bubble sord with loop removed, needed to find the largest side. last if statment makes sure that largest side is less then sum of 2 others and returns "true", otherwise the triangle is impossible so the function return false. Good luck on your exam |