Introduction to C
C is a general-purpose, procedural computer programming language. It was developed to write operating systems and compilers. It is also used for writing databases and web servers.
C in brief
- Middle-Level Language: C is a middle-level language, which means it has combined features of high-level languages and assembly language.
- Fast and Efficient: C has direct access to the hardware since it is a middle-level language. Due to this nature, C is very fast and efficient.
- Easy to learn: C is a very easy-to-learn language, as it is simple and easy to understand. Moreover, it is easy to switch from C to other languages.
- General Purpose Language: C is a general-purpose language, which means it can be used for many purposes, like writing operating systems, compilers, databases, web servers, etc.
Why C?
- Learning C helps you to learn how programming languages, the internal architecture of a computer, the hardware, the operating system, and the compiler works.
- After C, it will be much easier to switch to other languages, like, C++, Java, C#, etc.
- It is also one of the most asked programming languages in the interviews, which surely will reflect your programming skills.
Examples to begin with
C
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
int main()
{
printf("Hello World!\n");
return 0;
}
Output
Hello World!
Example Explained
In the above example, the C program starts with including a header file <stdio.h> that contains the definitions of the functions printf and return.
The program's entry point is the function main, which means the function main will be called first.
The function printf is used to print the string "Hello World!\n" on the console.
The function return is used to return the value 0 to the operating system, which means the program will end.
The program's entry point is the function main, which means the function main will be called first.
The function printf is used to print the string "Hello World!\n" on the console.
The function return is used to return the value 0 to the operating system, which means the program will end.