C Language
C Language
What is C?
C is a general-purpose programming language created by Dennis Ritchie at
the Bell Laboratories in 1972.
It is a very popular language, despite being old. The main reason for its
popularity is because it is a fundamental language in the field of computer
science.
Why Learn C?
It is one of the most popular programming languages in the world
If you know C, you will have no problem learning other popular
programming languages such as Java, Python, C++, C#, etc, as the
syntax is similar
C is very fast, compared to other programming languages,
like Java and Python
C is very versatile; it can be used in both applications and technologies
Syntax
You have already seen the following code a couple of times in the first
chapters. Let's break it down to understand it better:
Example
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
Example explained
Line 1: #include <stdio.h> is a header file library that lets us work with
input and output functions, such as printf() (used in line 4). Header files add
functionality to C programs.
Don't worry if you don't understand how #include <stdio.h> works. Just think
of it as something that (almost) always appears in your program.
Line 2: A blank line. C ignores white space. But we use it to make the code
more readable.
Note: The body of int main() could also been written as:
int main(){printf("Hello World!");return 0;}
Line 6: Do not forget to add the closing curly bracket } to actually end the
main function.