Category: Programming

  • C Quickstart Guide for Programmers

    Code Technology” by Markus Spiske/ CC0 1.0

    C as a second language.

    I have been writing code in some form for 11 years. Something that I do often is pick up another programming language in an attempt to learn new things and understand programming at a deeper level. When learning a new programming language there is always this period at the start where I want a quick start guide that will quickly go over the basic concepts of a language so I can start writing code straight away.

    This post will serve as that guide.

    Note: I am not an expert at C, I am learning along with you. I simply am curating the things that I have learned so that those the come after me can jump in a bit faster.

    Why should you learn C?

    • As of 5/12/25 C ranks as 3rd in the TIOBE index for the most popular language today
    • C excels at giving the programmer full control of the operating system and its memory
    • C is considered the lingua franca of the programming world, learning C can help you understand programming at a deeper level
    • Correctly written C is very fast and serves as a fundamental skill in systems and other low level programming.

    History of and Facts about C

    C Hello World Example

    Including this in a quickstart guide only as a way to give you a functioning program straight away and to see how some C code looks in action.

    • #include <stdio.h> – This line includes the header file for the standard I/O library. This includes the definition for printf.
    • int main() – The main function which serves as the entry point to the program.
    • printf(“Hello World”) – Prints out the text and adds a newline character at the end.
    • return 0 – Exit the program and return no errors.

    Data Types

    Data types in C

    • int
      • Range: -2,147,483,648 to 2,147,483,647
      • Size: 4 Bytes
    • char
      • Range: -127 to 127 or 0 to 255
      • Size: 1 Byte
    • float
      • Range: 1.2E-38 to 3.4E+38
      • Size: 4 Bytes
    • double
      • Range: 1.7E-308 to 1.7E+308
      • Size: 8 Bytes
    • void
      • Used to indicate the absence of a value
      • Can only be used for pointers and function return types

    Variable Declaration

    How to declare a variable in C

    TYPE IDENTIFIER = VALUE;

    int main() {
        int age = 42;
        float cash = 5322.47;
        double pi = 3.14;
        
        return 0;
    }Code language: C++ (cpp)

    Arrays

    How to create and use an array in C

    Array Declaration in C

    TYPE IDENTIFIER[NUMBER_OF_ELEMENTS];

    int main() {
        //Creates an array of type int
        //Contains 4 elements
        int ages[4];
        
        return 0;
    }Code language: C++ (cpp)

    Array Initialization in C

    Initializing an array in C is very simple and similar to declaration.

    int main() {
        int ages[4] = {29,38,42,19};
        //You can omit the size when 
        //initializing on the same line
        int ages[] = {29,38,42,19};
        //Init all values to 0 (Or something else)
        int ages[4] = {0};
        
        return 0;
    }Code language: C++ (cpp)

    Functions

    How to create and use a function in C

    Function Declaration in C

    [KEYWORDS][RETURN TYPE][IDENTIFIER](PARAMETERS)

    int sum(int num1, int num2){
        return num1 + num2;
    }Code language: JavaScript (javascript)