Welcome to Anything Forums! We are a general discussion forum that believes in freedom of expression and aim to provide a low moderation (within reasonable means) environment to discuss any topic. If you want to join, simply click HERE to be taken to our account management system where you can make an account. If you had an account at iceteks.com, anythingforums.com, uovalor.com or uogateway.com in the past it has been transfered over and you can simply do a password reset.
Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
THanks for helping for the last one...i figured my way through
so now im actually gunna continue getting help .
ok you have to use if commands and only + / - * . and NO turing built in functions to tell the user if the number entered by the user is a real number or integer.
i know it sounds easy but i have NO idea how i can do this.
plz help ill be reaaaallly grateful.
EDIT: oh yes and i use the windows version OOT
Archived topic from Iceteks, old topic ID:2864, old post ID:23403
Yes, turing has to have the type enforced. You can't just sneak away without telling the computer what TYPE of variable it is. The only way the computer can tell without you specifying the type is to assign it a value. For example, if you say VAR X := "hello" turing will automatically associate it as a string. However, it is a good practice to assign the TYPE to your variables. That way, you'll know what they are in the future. Oh, while I'm on this subject, might as well tell you about commenting. Commenting isn't really executable coding in a program (which means that it does not affect how the program is run), but it is extremely important. Here's an example of commenting
%This is a comment
The coding for comments requires a single % symbol, then anything after it. What does commenting do? Well, it simply puts lines of text in the program. It doesn't do anything special to your program or anything. HOWEVER, it can prove to be most useful. You use commenting to talk about parts of your program. For example, you come to a part of your program, and while programming, you comment to tell others what your program will do. I use commenting alot for variables. I comment my variables and explain what each variable will do and why it is used. When your programs start to get really big (EX: 4000 lines), you'll NEED commenting to know where things are going to go. Commenting is also useful for setting link points in your program. If you need to find something, give the comment a unique name such as %MAIN PROGRAM and just go into the turing menu, select FIND WORD and type that in. The result is the program will jump to that line of text and bring you where you go (Very useful, saves time in trying to find an area of code). Here's an example of commenting variables:
%VARIABLE X: This variable is used in calculating the length of an object. It is given %the default value of 0 and is used in the area formula
VAR X: INT:= 0
This just explains what X will do. You see, before you even see variable X being used, you have a rough idea of what it will do. The next one is using a comment as a link point:
LOOP
PUT "HELLO"
END LOOP
If h = true then
end if
%CALCULATIONS
LOOP
%coding
%coding
END LOOP
%MAIN
FOR I: 1..3
%Lines of code
END FOR
You see, I have 2 linking comments. One being called CALCULATIONS and one called MAIN. So, no matter where I am in the coding of my program, all I have to do is select the FIND WORD section and type in MAIN, then the program will jump to that area and bring me where I need to go. So that's basically commenting. Commenting is simple, yet affective, especially if you are working in a group project or you decide to take a break from programming something for a very long time. That way, when you or somebody forgets what the variable or the program does, you can easily find out.
Archived topic from Iceteks, old topic ID:2864, old post ID:23408
i am asking that i have to make a program where user puts a number THEN the computer will tell the user whether they put a real number or an integer. and the outlines i already stated in my last post..
someone plzz help me
Archived topic from Iceteks, old topic ID:2864, old post ID:23410
var number : int
get number[code]
Or maybe:
[code]var number : real
get number[code]
In either case, you've already stated whether the variable is an integer or floating point number.
What I suspect you mean, though, is, given that you declare the variable as a real, you want to know if someone just typed an integer anyway.
This is easy to find out. The basic process is to get just the integer part of the number, and compare it to the original. If they're the same, then clearly there was nothing after the decimal point.
The floor function will take a floating point number, and give you just the integer part.
[code]var number : real
get number
if number = floor (number) then
put "int"
else
put "real"
end if[code]
[color=#888888][size=85]Archived topic from Iceteks, old topic ID:2864, old post ID:23414[/size][/color]
I know how to do that. You need to use a function called MODULUS. It's a built in function, called in an if statement. The coding is MOD. I hardly ever use MOD because I don't find it particularly useful. Although I don't remember the EXACT syntax, I'll be able to explain what it does. I believe that MOD takes a number and checks to see if it has remainders or not. If it does not have a remainder, MOD returns the value of 0 and if it DOES have a remainder, it returns the value of 1. You'll have to research about MOD in your turing manual (you do have one, riiiight?). But All I think you have to do is take the number, and MOD it to check if it has remainders or not. Obviously, if it has a remainder, it is a real number. Otherwise, if it has no remainders, it is an INT (Well, it's a real too, but that's beyond the point.). Anyways, if anyone else can remember what MOD does and how to use it, feel free to elaborate. I on the other hand, am out of brain juice and I don't have turing anymore to test my theories. EN JOY!
Archived topic from Iceteks, old topic ID:2864, old post ID:23426
Sure, why not? I should really start up my programming again (Now that I have time ). Ya, I haven't learned all the new turing commands like the GUI stuff, but I probably would like to figure them out. A programmer can only explain so much without actually testing things out. Sure if I have turing, I'll DEFINATELY be able to figure out that previous question (I have a hunch, but needs testing) .
Archived topic from Iceteks, old topic ID:2864, old post ID:23438
var number : real
get number
loop
exit when number < 1
number := number - 1
end loop[code]
If your teacher says you can't use loops, hit him or her for me, ok? :)
[color=#888888][size=85]Archived topic from Iceteks, old topic ID:2864, old post ID:23448[/size][/color]
LOL. Ya, your teacher must be a moron. I don't think SHE even knows how to do it. Still, it can't be as bad as MY programming teacher. Pretty sad when the student knows more than the teacher. Anyways, my email is muitto101@hotmail.com.. Send it whenever and I'll be able to check out that MOD operand. Although I think that question was answered.
Archived topic from Iceteks, old topic ID:2864, old post ID:23472