Everything In Between

The brutally honest, first-person account of Meitar Moscovitz's life.

Archive for the ‘C/C++’ Category

Random Thoughts and Fibonacci Sequences

2 comments

I know I promised more writings on bipolar disorder. In a rather fitting and repetitive twist of fate, I was feeling too moody to write about being moody.

Instead, in order to keep myself from feeling unproductive, I started learning C programming. After trying the obligatory “hello world” program, I made a simple guess-my-birthday game. After that, I wanted to learn how to parse command-line options and arguments. I first needed an application that could take options, however, so I wrote a quick ‘n dirty Fibonacci sequence calculator. The first incarnation used an array to allocate some appropriate chunks of memory and then performed the calculations in one pass over the array.

It was simplistic, but wasteful. After posting a messag to the Orkut C Programming community, it was suggested that I use a recursive function to calculate the sequence. One number at a time is simpler and more memory-efficient. So I re-wrote the core function. Finally, I added switches for both starting numbers and the length of the sequence option.

Would like to see if I can add a few other options just for similar academic purposes like a delimiter (instead of the default newline) and an output file.

Other thoughts:

  • Really don’t like the idea of keeping two separate sites (one for BPD, one for my work). I think I’ll combine both blogs into one and just turn feed the Maymay Media site blog postings from appropriate categories that I post here.
  • Both these sites need redesigns. Would be willing to hire designers to get the job done.
  • I missed the opportunity to register to vote. That’s frustrating but I have only myself to blame.
  • Apartment hunting has proven fruitless for the time being. I also hate the idea of not living within three blocks of everything.

Written by Meitar

October 21st, 2004 at 4:06 am

Outsmarted again!

4 comments

I’ve been learning how to create C programs, for no real reason other than academic interest. Tonight I gave it my second shot and wrote a program that should convert your weight from pounds to kilograms. So I showed it to Danica but, as usual, she was smarter than the program I wrote:

Danica outsmarts my program by supplying unexpected input to a question about her weight.

Crap.

Written by Meitar

October 12th, 2004 at 10:51 pm

Posted in C/C++,Personal