Elite Fitness Bodybuilding, Anabolics, Diet, Life Extension, Wellness, Supplements, and Training Boards
Chat & Conversation Anyone know how to use TURBO PASCAL?
|
Author | Topic: Anyone know how to use TURBO PASCAL? | ||
Pro Bodybuilder Posts: 501 |
if you do please email me or reply to this message, thanks! ------------------ | ||
Pro Bodybuilder Posts: 367 |
what do you need to do? ------------------ | ||
Pro Bodybuilder Posts: 501 |
i need to write a program that asks the user to input in a number and the computer should display if the number is a prime numbr (a number that can only be divided by 1 or itself) aky ------------------ | ||
Pro Bodybuilder Posts: 367 |
I could write out the whole program for you, but then you wouldn't have learned a thing. So what part of what you just said don't you understand how to do - and is it b/c you don't get the math, the idea, or you don't know how to do it in TP? If you give me the specifics of what you need, but not the whole problem, then I can tell you how to do that. Have you written any code yet (prior to this - or also have you started writing code for this problem)? ------------------ | ||
Pro Bodybuilder Posts: 501 |
i've been in this class for 3 weeks and before this class i was in a class called Programming concepts, and yes i've written pseudocode. Ok i'll be more specific.. my question is i dont know how to use the function. I am suppose to use a function to determine if a # is prime or not. I just need help getting started... a kick start! aky ------------------ | ||
Pro Bodybuilder Posts: 367 |
So are you saying the teacher provides you with a function that will report if it is prime or not? If that is the case, then you are practically done. Here is thought process I would go through on writing such a thing: I need to talk to the user of this program, I need output text to the screen that will let them know they need to perform an action in order for this to work. I then need to take ina value, and then store it in a variable. I then need to take this stored value and look at it and do a calculation on it. Once I've determined if this is prime or not, then I need to, one last time, write to the screen and let the user know to which side the outcome resulted in - prime or not. do you have a textbook or manual for the class? ------------------ | ||
Pro Bodybuilder Posts: 501 |
you have mail they dont provide us with the function... they just tell us that we have to use one... also i know how to do everything you mentioned except how to write the function and how to calculate if the number is prime or not. aky ------------------ | ||
Pro Bodybuilder Posts: 501 |
bump ------------------ | ||
Pro Bodybuilder Posts: 367 |
I'll check my mail and get back to you. ------------------ | ||
Pro Bodybuilder Posts: 367 |
quote: I checked my e-mail but something went wrong and hushmail wouldn't let me open the letter. okay, well a function is just a chunk of code that doesn't get run unless you call it - and when you call it, you can pass it things, it will then do stuff, and it can then return suff back to you. It has been awhile since I wrote anything in TP (it sucks), but I think it is called a procedure in TP - so look that up in your book and/or for the class. pretty much you are going to have a funtion like so - with the working parts between for the working parts you will want to make use of a built in math function called "mod" - modular arithmatic outputs the remainder of division. so if I said 4 mod 2 - that would output 0. if I said 7 mod 2 - that would output 1. ------------------ | ||
Pro Bodybuilder Posts: 501 |
i know all about the procedures... all i am stuck with is how do i make TP determine if a number is a prime or not??? You said to use a math function (mod) i know how this works and all but not sure how to set it up to try any # that is inputted??? please help, you seem like the only one who knows about TP!!! aky ------------------ | ||
Pro Bodybuilder Posts: 367 |
Okay. You said you know how to get a value in from the screen. That value that comes in is what you want to check to be prime. Fantastic. You said you know about procedures, so this is where you will put the pirme figuring code. Fantastic. You say you know how to use mod - perfect. Now look up how to do loops - a for loop is probably what you want. I'll write this in pseudocode here - if you want I can write it in some other language (even can be easily done in javascript - which might as well be pseudocode it is so easy) for you too - I just don't feel that I should write out the code in TP for you b/c that is just doing your work for you. function isPrime(i) inputValue = readValue(X)
That really should do it there. I'm not going to write the TP code for you... you should learn... I a frickin hate TP. ------------------ | ||
Pro Bodybuilder Posts: 501 |
Thanks for all you help... i'll try to write it out and see how it goes.... well i'm going to class right now, and i'll put a post later on tonite to let you know... ya i know what you mean... i hate this shit too aky ------------------ | ||
Pro Bodybuilder Posts: 501 |
well bro i've tried all week and cant figure it out.... i just cant get it.... if you can help me further that would be awesome. But if not that's ok too... i just need an example to look at then i can refer to it... i'm not going to copy it because then i'll flunk the exam... the best way to learn (for me) is from similar examples.... hope you can help... but thanks for everything so far.... aky ------------------ | ||
Pro Bodybuilder Posts: 367 |
okay - read in the value. I think that is readln in TP. Then dump that value to your function. have that value work on it. have that value return an answer. output that answer. so (it has been awhile since I've used TP so I'm not positive on the syntax - but you have a book on it): procedure isPrime(i:integer); writeln("Enter a number:");
that really should do it. so it would look like this to the user: Enter a number: (they enter 5) or Enter a number: (they enter 6)
good luck - that is all I can do for you. ------------------ | ||
Pro Bodybuilder Posts: 501 |
thank you, this will be awesome... aky ------------------ |
All times are ET (US) | |
Powered by Infopop www.infopop.com © 2000
Ultimate Bulletin Board 5.45c