My history with computer programming starts 15 years back with BASIC and ends with C, 10 years back. I learned BASIC as a part curriculum in school and tried to learn C as a extra curricular activity. C was particularly entertaining at that time, I specially remember making a program which draws a circle on the screen and bounces it of the screen edges. But that was as far as I went and didnt required any programming in particular after that.
For long time, I have been feeling that my computer programming skills are terribly outdated and some time or other I would be requiring it in my endeavors. Recently I have been coming across lots of references to programming while trying to make complex analyses over AutoCAD and GIS. Though I tried to learn visual basic and many scripting languages (Ruby, Avenue, scripting in Autocad etc), I was mostly satisfied with searching for a piece of code over internet and using it. But recently, a series of ideas over few analytic techniques and lack of a simple android application to capture and store android GPS data in a meaningful way for my work has kindled the programming fever in me again.
I chose “C” again since that is the only language I have a little grasp over and also is one of the widely use, highly portable higher level language in market place. and it doesn’t require a fancy integrated development environment like visual studio for even simple programs. It was perfect for someone like me who is starting programming. So after choosing the language next was the hunt for the compiler. I settled for digital mars compiler since it was a portable installation (can be used in my office computer) and didn’t pose much hassle to install and execute.
After setting up and writing a large number of hello world programs, Today I decided to take on a problem head on. It was a simple exercise – to find the distance between two points provided their latitude and longitude. I started by formulating the whole exercise as big formula and simplifying it breaking down each part of the formula into a different variable. First road block came when I hit the problem of calculating sin and cos values. The functions of sin() and cos() didn’t seemed to work for some unknown reason and after half an hour of trying I just assumed the functions won’t work in my system. So started to go in the direction of calculating the sin and cos values (remembering trigonometry after 6 years). After frantic searching on the internet I finally decided to go with taylor series (Big Mistake) and calculate the initial parts of the series for an approximate value.
So that gave way to the next problem – Apparently one cannot use “^” symbol for exponential operations and also there is the question of solving factorials. I started with the factorial thing and solved it through a bad combination of “IF” command and “Goto” command. I even went on to make a function call within the program so that I can calculate factorials for all the instances I wanted. Now the exponential thing started giving me problems since the pow(x,y) function was also not working. After 30 minutes of frustrated searching I found out that you have to include <math.h> library for the function to work. So included the library, compiled the program and was ready test my first real program.
The results were bizarre! After testing it with a couple of co-ordinates from Google earth I decided the program is hopeless. The errors were huge, sometimes it was more than 150% of the original value. To understand where the problem is arising I started printing all the variables I calculated in the program and compared it with a hand calculated version. Then I realised the taylor series method i formulated to calculate the Sin and Cos values were not working at all (Should have checked them a lot earlier). Now when i started to work on in it again it struck me that sin() functions were not working earlier due to the math.h library. Now I started replacing one and half hour worth code with a simple inbuilt function (factorial function is also useless now) and the program started to look like a simple math problem in the examination which got extended to waste paper. But anyways atleast I completed the program and tested for a more accurate results!! (VICTORY!!!)

Still there were some inaccuracies which disappeared after making the radius of the earth and value of pi more accurate. After 30 min of testing, when I was satisfied with the results, I started working on the user interface part of the program. Since it was a MS DOS based program, All I can do was name the program, include an ASCII art, Add author information and put up a basic description of the program. after 30 min of struggle (thanks to the sign!) I got the layout to work perfectly and proudly compiled my first serious program with some value!.
Now having crossed the first step, I am thinking of venturing into more challenging projects. It would be great if some one can suggest a simple, challenging (for mere mortals) , interesting and practical projects which I can work upon. I have attached the program and the source code with the post for testing and reviews. 😉
http://sourceforge.net/projects/discalv/files/Discal.exe/download
http://sourceforge.net/projects/discalv/files/Discal.c/download
update: As requested by Kyle Rayner, Included a loop in the program so that there is no need to re-start the program every calculation and compiled a v1.1,