So I am new to programming and I pretty much wanted to create a simple program to test Trigonometry

On the TI 84.

You have a program that displays 5 questions in 60 sec.

It asks a cos/sin/tan/cot from 0°,30,45,60,90,120,135,150,180,210,225,240,270,300,315,330 or 360° (and -1000° until +1000°) when the 60 seconds are over you have to see the (simplified) answer.

The problem is to actually get a random degree. I can create a list of all these numbers but how do I pick one randomly? While showing the answer afterwards?

Any help would be greatly appreciated.

```
:{0,30,45,60,90,120,135,150,180,210,225,270,300,315,330
:Ans(randInt(1,15
:Ans+360randInt(-3,3→A
```

Like that?

Ooh! I made a trig testing program once, it was good but then my ram got cleared :(

I would use one of the other's methods of randomly choosing a number, then do something like this:

F refers to the trigonometric function, 1=cos 2=sin etc… I'll just show cos for time's sake. θ is the angle.

```
:If cos(θ)=iPart(cos(θ))
:Then
:cos(θ)→Str1
:Else
:1→A
:While θ>360
:θ-360→θ
:End
:While θ>90
:θ-90→θ
:A+1→A
:End
:If F=1
:Then
:If θ=60:"1/2"→Str1
:If θ=45:"√(2)/2"→Str1
:If θ=30:"√(3)/2)"→Str1
:If A=2 or A=3:"-"+Str1→Str1
:End
:End
:Disp Str1
```

I haven't tested this, but I think it should work.

The :If cos(θ)=iPart(cos(θ)) line is a trick I use to check if a number has a decimal or not. It compares the integer part (iPart) of the number to the original number, and if they're the same, you know that it's a whole number.

I haven't looked at ways to really analyse your code, yet, but I do see one problem and a few optimisations :)

The :If cos(θ)=iPart(cos(θ)) line is a trick I use to check if a number has a decimal or not. It compares the integer part (iPart) of the number to the original number, and if they're the same, you know that it's a whole number.

It is cool that you figured that out! You can also use 'If not(fPart(cos(θ' to accomplish that because fPart( returns the decimal part of the number (or "fractional part"). But the only times when cos(θ) will be an integer is when it is 1,0, or -1.

Among the other optimisations I see, you won't actually need ending quotes or parentheses before a newline or '→' token. For example, your first line could be optimised to:

`:If cos(θ)=iPart(cos(θ`

The problem that I saw was with this line:

`:cos(θ)→Str1`

Unfortunately, it is not that easy to store a number to a string. Since you only have three cases 0,1,-1 and the squares of those are 0 or 1:

```
sub("01",1+cos(θ)²,1
If 0>cos(θ
"-"+Ans
```

In your while loops, you are doing something called a modulo function. For example, 405 modulo 360 is 45. A trick that will work on all OSes is:

`θ-360iPart(θ/360`

It will probably actually work if you do:

`360fPart(θ/360`

However, the latter method is known for having rounding issues, so you should test it. I think it should be fine in these cases. Then, immediately after you want to compute A with a similar process:

`1+iPart(Ans/90→A`

And then, just to be tricky with the last part:

```
:If F=1
:Then
:If θ=60:"1
:If θ=45:"√(2)
:If θ=30:"√(3)
:Ans+"/2
:If A=2 or A=3:"-"+Ans
:Ans→Str1
:End
```

So to put it all together and optimising further:

```
:cos(θ
:If not(fPart(Ans
:Then
:sub("01",1+Ans²,1
:If 0>cos(θ
:"-"+Ans
:Else
:θ+1080 ;we need to account for negative numbers. 1080 is a multiple of 360 and outside your range, so it will make any value positive.
:Ans-360iPart(Ans/360→θ
:iPart(Ans/90→A
:θ-90Ans→θ
:If F=1 ;not sure what you use this for
:Then
:If θ=60:"1
:If θ=45:"√(2)
:If θ=30:"√(3)
:Ans+"/2
:If 2>A
:"-"+Ans
:End
:End
:Ans ;If this is the end of the program, you actually don't need Disp. If it isn't, use 'Pause Ans' or 'Disp Ans'
```

I hope that is helpful and clear (ish). If you have questions, definitely ask!

47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2

Wow, that was a lot :P The ending quotes are holdovers from 68k Basic, the 89 kind of freaks out if you forget an ending quote or paren… even on the home screen… Same with cos(θ)→Str1… you see, in 68k it really is that simple :)

Got to say though, high five for the

```
:If θ=60:"1
:If θ=45:"√(2)
:If θ=30:"√(3)
:Ans+"/2
:If 2>A
:"-"+Ans
```

section…. that's really cool :)