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

Username:   Password: 
 RegisterRegister   
 Turing Calculator (Simple)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
The Rookie




PostPosted: Sat Oct 12, 2013 9:54 am   Post subject: Turing Calculator (Simple)

What is it you are trying to achieve?
Turing Calculator Square Roots


What is the problem you are having?
How would I add square roots to the code?

Describe what you have tried to solve this problem
I have tried to search elsewhere but the answers were not helpful.

Turing:


%Variables
var num, num2 : real

%Questions
color(purple)
put "Program by Mishil Desai."
put "This calculator works by entering 2 numbers. The results will then be displayed."
loop
 color(black)
 put "================================================================================"
 put "Enter first number:"
 get num
 put "Enter second number:"
 get num2

%Outcomes
 color(blue)
 put "________________________________________________________________________________"
 put "________________________________________________________________________________"
 put "Added = ", num + num2
 put "Substracted (First - Second) = ", num - num2
 put "Substracted (Second - First) = ", num2 - num
 put "Multiplied = ", num * num2
 put "Divided (First / Last) = ", num / num2
 put "Divided (Last / First) = ", num2 / num
 put ""
end loop

%Program by Mishil Desai



Please specify what version of Turing you are using
Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Nathan4102




PostPosted: Sat Oct 12, 2013 10:41 am   Post subject: RE:Turing Calculator (Simple)

Are you trying to square the sum of the numbers? The difference? The single numbers?

The sqrt(number : real) function is what you're looking for.

Turing:
put sqrt(9)
%Outputs 3
Raknarg




PostPosted: Sat Oct 12, 2013 12:43 pm   Post subject: RE:Turing Calculator (Simple)

You can use the predefined sqrt or you can use exponents. For example:

4 ** 2 = 16

16 ** (0.5) = 4

Just use two stars as opposed to one
MasterCard




PostPosted: Sat Mar 12, 2016 1:13 pm   Post subject: RE:Turing Calculator (Simple)

Made a tutorial!

https://www.youtube.com/watch?v=pkGDWe3nReQ&index=3&list=PLs9jD_F5glNZOnJnHazosDUFENaXbv_vy
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  [ 4 Posts ]
Jump to:   


Style:  
Search: