Chapter-1 (Introduction of C)
C Language:-
Human Language: Human languages like English, Hindi, etc. are natural languages used for communication between people. They are diverse, complex, and varied across different cultures. Humans use languages for expressing thoughts, ideas, and communicating with each other.
Machine Language: Computers, on the other hand, can only understand machine language, which is a binary code consisting of 0s and 1s. Machine language represents the lowest level of abstraction and is directly understandable by the hardware. It's the language that the central processing unit (CPU) of a computer operates on.
History:-
Dennis Ritchie developed the general-purpose programming language C at Bell Laboratories in 1972.
Despite its age, this language is still very popular. The primary cause of its widespread use is that it is an essential language in computer science.
Why should you learn C?
1. It is one of the world's most popular programming languages.
2. If you know C, you will have no trouble learning other popular programming languages such as Java, Python, C++, C#, and so on because the syntax is similar.
3. C is extremely fast when compared to other programming languages such as Java and Python. C is a very versatile programming language that can be used in both applications and technologies.
Difference between Compiler and Interpreter:
Compiler:
- 1. Operation: A compiler translates the entire source code into machine code or intermediate code before execution.
- 2. Execution: It generates an executable file or a binary that can be executed without the need for the original source code.
- 3. Process: The compilation process occurs in two stages: analysis and synthesis.
- 4. Performance: Compiled code usually runs faster as the entire code is converted beforehand.
- 5. Error Handling: Errors are identified after the entire code is checked. Compilation fails if errors are found, and the programmer must correct errors before execution.
Interpreter:
- 1. Operation: An interpreter directly executes the source code line by line without the need to create an intermediate file.
- 2. Execution: It doesn't produce an independent executable file but interprets the code during runtime.
- 3. Process: It translates and executes the code line-by-line on the go.
- 4. Performance: Interpreted code generally runs slower compared to compiled code due to the real-time translation process.
- 5. Error Handling: Errors are identified as the code is executed. The interpreter halts execution when an error is encountered but can continue with the remaining code if errors are fixed.