www. Jacob   Zimmerman .com



My first programs

Spring 2021
Published: January 21, 2024

This code is here for me to reminisce and remind me of my progress. At the time of publishing, it has been about three years since I wrote my first line of code. A lot has changed in my life because of these programs.

I was an anthropology major, when I decided to take Tuft's notorious Introduction to Computer Science course after friend said I might like programming. Even though I enjoyed the course, it was a bit of time after before I decided to switch my major to CS.

It's also here to test out the syntax highlighting on my not-so-fancy new website.

hw00: hello.cpp
//this is a comment?//

#include <iostream>

using namespace std;

int main()
{ 
    /*this is a comment, just so you know what it looks like*/
    //name//
    cout << "Hi my name is Jacob Zimmerman." << endl;
    //age and hometown//
    cout << "I'm a sophomore and I live in Philadelphia." << endl;
    //interests//
    cout << "I like soccer and painting and adrenaline." << endl;
    
    /*  cout < "I never make mistaks" << endl;  */
    //Line above is an intentional ERROR, missing a < after cout //
    
    return 0;
}

hw01: add8.cpp
Check out the "complex function" that took me a long time at the end. Very cute.

// Add 8 number inputs together and print sum
// Creator: Jacob Zimmerman     Date: 2/16/21
// This code took a long time and lots of review of lecture slides
// The goal of this program is to add 8 numbers with only 2 variables 
// by using functions


// It would be quite easy to use 9 variables and just ask to add them, but 
// now I can easily increase the number of numbers to sum


#include <iostream>
#include <cmath>

using namespace std;

//declaring functions
float get_number();
/* variable number and sum have no meaning, and they will be replaced
 by the variables input_number and answer in the function */
float add_sum(float number,float sum);


int 
main()
{
    //creating the two main variables. answer means final sum
    float answer ;
    float input_number ;
    //the answer has to start at 0
    answer = 0 ;
    //1st number
    
    //call get_number and use that as input_number
    //add input_number to total answer
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //2nd number     Repeat above
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //3rd number
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //4th number
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //5th number
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //6th number
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //7th number
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    //8th number
    input_number = get_number() ;
    answer = add_sum(input_number,answer) ;
    
    //Return and print answer 
    cout << "The sum is: " << answer << endl;

return 0; 
}    
//this is a basic function just to get the input_number
//this function is kind of unneccesary. But helps to shorten and practice funcs
float
get_number()
{
    float new_number ;
    cout << "Enter a floating point number: " ;
    cin >> new_number ;
    return new_number ;
}


/* This is the more complex function that takes the input number and adds it to
the total sum */
float
add_sum(float number,float sum){
    sum += number ;
    return sum ; 
}

    

One last piece of treasure

A written response to hw00 about why I took a programming class. Man I was so spot on. It took me three more years of coding and a readthrough of 'Mindstorms'[0] to rediscover this sentiment.


Notes and Refs: