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

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




PostPosted: Thu Nov 27, 2014 12:34 pm   Post subject: Square roots

What is it you are trying to achieve?
I'm trying to finish an assignment.


What is the problem you are having?
How would I do this?
"Write a program that asks the user to enter a positive integer. The program determines whether the square root of the integer entered is an integer. If the square root is an integer, display the value of the square root, otherwise display ?the square root is not an integer?. Your program may NOT use a fractional exponent or the built?in Turing square root (sqrt) function."


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.1 Version 1.0.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Nov 27, 2014 3:46 pm   Post subject: Re: Square roots

asdfasdf123 @ Thu Nov 27, 2014 12:34 pm wrote:
I'm trying to finish an assignment.

How much of the assignment do you have done? What do you have left to do?

It would be helpful to express the problem in your own words, simply to encourage yourself to understand the question well enough to do so. The followup will be "what is the first step?" which should really be read as "what part can you do right now?".

Getting user's input could be a good place to start. You can then even prototype the output part, if you have a placeholder for the middle (e.g. pretend that only 9 is a number with a square root).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
asdfasdf123




PostPosted: Fri Nov 28, 2014 12:00 pm   Post subject: Re: Square roots

I can't figure out how to find the square root of the user's input without using fractional exponents or the sqrt function, and I don't know how to determine whether or not it's an integer.
DemonWasp




PostPosted: Fri Nov 28, 2014 12:37 pm   Post subject: RE:Square roots

You don't have to do that. Try looking at the problem backwards: if you have ONLY multiplication and for-loops, how can you figure out whether a number is a square of an integer?

Hint: you can easily compute the square of a number using only multiplication.
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: