C Programming — intro.

Michelle Juma
3 min readMar 21, 2022
C programming

Late in publishing this article but that was because I was trying to grasp the many concepts I learnt the past one-two weeks.

I just wrote 1–2 cause Scuderia Ferrari got those positions yesterday. Yaay! I digress.

C is an interesting language.
It was designed by a certain Dennis Ritchie and his pal to build operating systems , the concept that is.
This language is strongly associated with the UNIX operating system but with time it became friends or rather compatible with almost everything.
Hence being used to develop most systems we have today , from embedded systems to Doom3a first-person horror shooter game was designed by id Software for Microsoft Windows using C in 2004.

Structure of a ‘C’ program .

  1. Header
    It includes .h files . ie main.h .
    Files with this extension act as a liaison between the source file and header file. You can write your functions in header files and import them to your source file.
    This is achieved by adding #include file_name.h in the file_name.c
  2. main ()
    This is where you declare your main function and the rest follows.
    Example are : int main(), void main ()
  3. Variable Declaration
    We declare the variables to be used after just stating our method . They are declared using the different data types we have in programming.
  4. Body
    We write our function and print the result on the body.This is where we write what we want our code to do.
  5. Return statement
    This is like our exit code or terminates our main function . It is usually 0, but we can make it return something else , depending on our function.

The code snippet below can help us visualize the structure:

#include <stdio.h> --- header 
int main() --- main declaration
{
int a; --- variable decalration

printf("%d", a); --- body of function

return 0; --- return statement
}

Functions.

Functions are same across the programming spectrum , just executed differently.
Such like , do while , if , if..else, switch statements. The likes.

Debugging.

This is the process of finding bugs (defects or problems that prevent correct operation) within computer programs, software, or systems.

Interesting things I learnt the past few weeks.
1. Betty Linter.
Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. ALX it uses the betty method. One word . Tasking.

/**
* main — function
* Description: describe what the function does
* Return: always return 0 / 1 depends on the function
*/

The above snippet is an example of how to write a betty documentation /syntax.

2. Heisenbug
This is a fun concept. A software bug that alters itself if you attempt to study it — Namely-punned as the physicist who first asserted the observer effect of quantum mechanics.
Simply put, some errors can occur during compilation cause the code looks at itself causing it to alter itself . This can lead to long run-time executions.

Real life example : Dancing aimlessly in your bedroom, till your sixth sense alerts that you are being watched.

We are currently learning on pointers, arrays . My commit count so far : 329.

So far, so good.

--

--