I don't know if anybody else listens to Tegan and Sara but it's unrelated. They do have a song titled
The First but that's not what this thread is about.
This thread is actually about the first program you've ever written. I of course am referring to something other than a "Hello World!" program; I'm thinking more along the lines of the first program you ever wrote for yourself based on what you'd learned to do. I've been programming actively for over 5 years now and I don't know that much about mainstream programming to be honest since the majority of my work is done with a game engine that has its own language. I do know some C++ and php. Enough to get me by anyway.
I was just thinking last night about the first program that I ever wrote. It was when I was in 9th grade and I wrote a program for my
TI-83 graphing calculator. It was a pretty basic concept involving the slope-intercept mathematical formula which reads as:
CODE
y = mx + b
Given this formula, taking the basic principles of algebra we can also solve these:
CODE
m = (y - b) / x
x = (y - b) / m
b = y - mx
Given these four equations with any 3 known variables it would be a simple matter to solve for the fourth and final unknown.
One question that was posed to me by a teach later on that stumped me at the time but occurred to me as I was thinking back on it was, "How can you solve for the slope with only one point?"
Of course looking at the above formulas if X == 0 then there would be a divide by zero error so we can assume a point at (0,

as well as at (X, Y) which gives the two points needed for the validity of the formula to solve for slope.
So anyway, I just rewrote the program since I no longer had it. Here's the full source:
CODE
ClrHome
Disp " Y=MX+B","","SOLVES THE SLOPE"," INTERCEPT"," FORMULA FOR","A SINGLE UNKNOWN"
Pause
Lbl W
ClrHome
Menu("WHICH UNKNOWN?","Y",Y,"M",M,"X",X,"B",B)
Lbl Y
ClrHome
Prompt M,X,B
ClrHome
MX+B→Y
Disp "Y=",Y
Pause
Goto A
Lbl M
ClrHome
Prompt Y,X,B
ClrHome
If X=0
Then
Disp " X MUST BE"," NONZERO","","PLEASE TRY AGAIN"
Pause
Goto M
End
(Y-B)/X→M
Disp "M=",M
Pause
Goto A
Lbl X
ClrHome
Prompt Y,M,B
ClrHome
If M=0
Then
Disp " M MUST BE"," NONZERO","","PLEASE TRY AGAIN"
Pause
Goto X
End
(Y-B)/M→X
Disp "X=",X
Pause
Goto A
Lbl B
ClrHome
Prompt Y,M,X
ClrHome
Y-MX→B
Disp "B=",B
Pause
Goto A
Lbl A
Menu("AGAIN?","YES",W,"NO",E)
Lbl E
ClrHome
Return
Anyway, I thought it would be interesting to see what some of you wrote as your first
useful program. I looked around and didn't see anything like this so sorry if I overlooked it.
This post has been edited by monkey_05_06: 18 May, 2009 - 11:11 AM