C is, in my humble opinion, the best programming language so far.
It's not an easy choice to do, specially with so many of them to play with, C++ with generic programming and the great STL, Java that was born cross-platform and have tons of modules and technologies, Fortran with super-duper-fast scientific libraries and extensions and so on.
The difference is that C is one of the most simple and at the same time the most poweful programming language. For instance, C's grammar is far more simple than C++'s and Java's, you can manipulate data at the assembly level and the ability to use pointers directly gives a lot of power to those that know what their doing.
Of course, even the best programmers can make mistakes using that amount of power and it's generally the case with C newbies but to program in C is to understand better how the machine works and that's a true power that few other languages can give you (yes, assembly is far more complicated)
Most people don't like reading lots of abstract concepts before actually see a line of code and that's why the first section is about an example. You'll probably understand what's happening even if you cannot reproduce it later and that's the best reason to show you an example.
/* Give a brief description and usage: * * mult.c - multiplication table * * use: mult number */ /* Include all necessary libraries */ #include <stdio.h> /* Define some values to the preprocessor (see later) */ #define RETURN_SUCCESS 0 #define RETURN_ERROR 1 /* This is a generic function */ int multiply (int a, int b) { return a*b; } /* 'main' is the entry point */ int main (int argc, char *argv[]) { /* * argc is the number of arguents (plus one for the program) * argv is the arguments themselves (so argv[0] is the name of the program) */ /* number chosen */ int number; /* temp varable to store current multiplyer */ int mult; /* stores the result of the multiplication */ int result; /* Check if we have an argument */ if (argc != 2) { printf("usage: mult number\n"); return RETURN_ERROR; } /* Convert the argument (text) to a number */ number = atoi(argv[1]); /* for each multiplyer, print the result */ for (mult = 1; mult <= 9; mult = mult + 1) { result = multiply(number, mult); printf("%d x %d = %02d\n", number, mult, result); } /* If we got here, everything is OK */ return RETURN_SUCCESS; }
Now, as C is a compiled programming language, we need to compile it:
shell> gcc -o mult mult.c
Check to see if there's an executable file on your current directory called mult. If so, we can execute:
shell> ./mult 8 8 x 1 = 08 8 x 2 = 16 8 x 3 = 24 8 x 4 = 32 8 x 5 = 40 8 x 6 = 48 8 x 7 = 56 8 x 8 = 64 8 x 9 = 72