Coding Journey Update: February 2017

I think the hardest part of trying to teach myself to code is knowing if I am following the right path to get me there. I really envy those people who can afford to go to school to learn. I have no doubt that having someone else writing out a learning road map and then being there to answer any questions you have about what they have written down is well worth the money but since I don’t have any money I am just going to have to do this journey the hard way. I always think that I am on the path to where I need to go but then find myself having to circle back and retrace my steps over and over again.

The last failed path that I followed was that last year I settled on to committing to doing Harvard’s CS50 online because I thought following their learning path would be my best bet but although I learned a lot of the video lectures I found that the guidelines that were written for the problem sets were beyond frustrating to follow and I would lose weeks and weeks of time trying to figure out the correct way to do the things that they wanted me to do.

I finally just gave up on it completely and went back and deleted almost all entries referring to it since I’ve decided that I am just going to now use it as a guideline of what it is that I am supposed to be learning and I deleted the entries because I rather not be constantly reminded in past entries about my past failures. I find that to be demotivating so I and rather just delete them all and start over with a fresh start again.

The one gift that CS50 did give me is that it did get me over my fear of C programming. I have always been intimidated by C programming and would of never chose to learn it as a language if CS50 wouldn’t of put me on that path so I do not consider the time I’ve put into it so far to be time completely wasted. I just know it is time to start on a new path because I am not willing to lose anymore of my life or my peace of mind to completing the problem sets that they assign anymore. It would be different if I had someone I could constantly turn to in order to hand-hold me through the part that I get stuck on but since I don’t I rather just stumble through by trial and error my way.

My goals for this month are to try and finish reading ‘Absolute Beginner’s Guide to C, second edition’ by Grey Perry. Learning from the book has also been an exercise in frustration because it was printed in 1994 and a lot of the code doesn’t want to work with my compiler. I would also like to at least get part of the way through ‘Up and Running with Git and GitHub’ on since my library card now gives you a free membership to the site.

Despite all the set backs in the last year and a half I think that I am actually starting to get to a point of where I feel a lot less lost when it comes to C programming. I’ve been wandering around in ‘the desert of despair‘ for so long that it has been a constant battle to not just quit but in the last few weeks things have been clicking a lot more in my head when it comes to programming.

Goals for End of March:
  1. Go back and read the article ‘Don’t Believe Anyone Who Tells You Learning To Code Is Easy’
  2. Go back and read the article ‘How to survive the desert of despair in your code-learning journey’
  3. Finish ‘Absolute Beginner’s Guide to C, second edition’ by Grey Perry
  4. Install and learn how to use Eclipse

C Programming: Program for making change

/* Header Files */
#include <stdio.h>
#define QUARTER 25;
#define DIME 10;
#define NICKEL 5;

/* Main Function */
int main()
/* Variable Declaration */
int amount;
int myquarters;
int mydimes;
int mynickles;
int pennies;

printf("Enter amount of change: ");

myquarters = amount / QUARTER;
amount = amount % QUARTER;

mydimes = amount / DIME;
amount = amount % DIME;

mynickles = amount / NICKEL;

pennies = amount % NICKEL;

printf("%d quarters, %d dimes, %d nickels, %d pennies\n", myquarters, mydimes, mynickles, pennies);

/* Main Function Return Statement */
return 0;

This example shows:

  • how to use the modulus operator

C Programming Program to Check Even or Odd (modulo operator)

/* */

#include <stdio.h>
int main()
int number;

printf("Enter an integer: ");
scanf("%d", &number);

// True if the number is perfectly divisible by 2
if(number % 2 == 0)
printf("%d is even.", number);
printf("%d is odd.", number);

return 0;

C Programming: Print your number (with do-while loop)

/* Header Files */
#include <stdio.h>

/* Main Function */
int main()
/* Variable Declaration */
int myvariable;

/* Start Do-While Loop */
do {

/* Get Input Value */
printf("Enter a number or enter '0' to quit: ");
printf("Your number is %d",myvariable);


}while (myvariable != 0);
printf("Now quitting program...\n");

/* Main Function Return Statement */
return 0;

This example teaches:

  • how to use a do-while loop to be able to have a quit condition


C Programming: Guess my number (using #define)

/* Source URL: */

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define lower_limit 0
#define upper_limit 10

int main(){
int number, guess;

srand( time( 0 ) );
number = lower_limit + rand() % (upper_limit - lower_limit + 1);

printf( "Guess the number between %d and %d: ", lower_limit, upper_limit );

while( scanf( "%d", &guess ) == 1 ){
if( number == guess ){
printf( "You guessed correctly!\n" );
printf( "Your guess was too %s.\nTry again: ", number < guess ? "high" : "low" );

return 0;

This example teaches:

  • how to defining a constant
  • how to use break

Goat Code CS50 Week 1: What Greedy.C should have taught me

I should have learned:

  1. The change-making problem
  2. What a greedy algorithm is
  3. Difference between float and double
  4. Variable conversion
  5. Typecasting
  6. The number entered by the user must first be turned into pennies to be able to work with the value as money because pennies are integers
  7. How the modulus operator works
  8. Modulo division
  9. Program for making change

C Programming: Program to add two numbers using command-line arguments

/*Source URL: */

#include <stdlib.h>

int main(int argc, char * argv[]) {
int i, sum = 0;

if (argc != 3) {
printf("You have forgot to type numbers.");

printf("The sum is : ");

for (i = 1; i < argc; i++)
sum = sum + atoi(argv[i]);

printf("%d\n", sum);

return 0;


C Programming: Program for argc() and argv() functions

/* URL Source: */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])   //  command line arguments
printf("Arguments passed through command line " \
"not equal to 5");
return 1;

printf("\n Program name  : %s \n", argv[0]);
printf("1st arg  : %s \n", argv[1]);
printf("2nd arg  : %s \n", argv[2]);
printf("3rd arg  : %s \n", argv[3]);
printf("4th arg  : %s \n", argv[4]);
printf("5th arg  : %s \n", argv[5]);

return 0;


  • You can use each argv element just like a string, or use argv as a two dimensional array.

Goat Code CS50 Week 2: What Caesar.c should have taught me

I should have learned:

  1. The Caesar Cipher and Modular Arithmetic
  2. How Unix and the C language were originally meant to work with each other
  3. The importance of the command-line in C programming
  4. Why windows doesn’t have a more well developed command line interface
  5. How the passing of command-line arguments work in C programming work
  6. String manipulation
  7. How functions work
  8. Converting a string to an integer with the stdlib.h library and the atoi() function
  9. Program to display lower-case alphabet using ASCII values [Code | Flowchart]
  10. Program to display upper-case alphabet using ASCII values [Code | Flowchart]
  11. Program to find ASCII value [Code | Flowchart]
  12. Program for argc() and argv() functions [Code]
  13. Program to add two numbers using command-line arguments [Code]
  14. Flowgorithm Caesar Cipher

C Programming: Print ASCII Value

/* Source URL: */
#include <stdio.h>
int main()
char c;
printf("Enter a character: ");

// Reads character input from the user
scanf("%c", &c);

// %d displays the integer value of a character
// %c displays the actual character
printf("ASCII value of %c = %d\n", c, c);
return 0;

This example teaches:

  • ASCII values
  • Use of %c with printf()
  • Use of %d with printf()