My first programs
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
#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
// 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.
- What do you hope to get out of this course? Why did you take it?
- There was an educational youtube channel I was using to supplement my Calc 2 class[1], it was the best presentation style I had ever encountered. Other viewers seemed to agree with my sentiments, and we all remarked how unique and well produced the animations were. Someone in the comments noted that the person who made the video had coded an entire program to create the animations. I began to realize the powerful tool that programs could be outside of the stereotypical data analysis or web design codes. I am not interested in computers necessarily, but rather the ability to use coding in less data-heavy fields and more in less traditional uses such as film editing, arts or social sciences.
- How do you feel about the course content thus far?
- I love the balance between understanding what is actually happening in the computer in class. Compared with pure coding in Labs. The course website is also extremely well made and clear.
- Name something you like to do outside of school?
- I like to write comedy sketches[2] and get lost in various woods.
- How long did you spend on this assignment?
- I spent 45 minutes.
Notes and Refs:
- [0]: Papert, Seymour, 'Mindstorms: Children, Computers, and Powerful Ideas' (1980). gotta read it
- [1]: 3Blue1Brown, 'Essence of Calculus' (2017).
- [2]: Let's all be grateful that didn't work out.