C is a general-purpose, procedural programming language developed by Dennis Ritchie at Bell Labs in 1972. It is one of the oldest and most widely used programming languages, known for its simplicity, efficiency, and close relationship with hardware.
Key Features of C
- Simple Syntax: Easy to understand and implement.
- Portable: C code can be executed on different machines with minimal changes.
- Low-Level Access: Provides direct access to memory via pointers.
- Modularity: Supports functions for modular programming.
- Efficient: Suitable for system-level programming (e.g., operating systems, embedded systems).
- Rich Standard Library: Includes libraries for I/O, math, string manipulation, etc.
Applications of C
- Operating Systems: Linux, Windows kernels.
- Embedded Systems: Microcontrollers and IoT devices.
- Compilers: Many modern compilers are written in C.
- Database Management Systems: MySQL, Oracle.
- Gaming: High-performance gaming engines.
Basic Syntax
C programs are written in a structured format and consist of the following:
- Preprocessor Directives: Includes necessary libraries.
- Main Function: The entry point of the program.
- Statements: Instructions executed by the program.
Examples of C Programs
1. Hello World Program
Output:
2. Program to Add Two Numbers
Output (Example):
3. Find if a Number is Even or Odd
Output (Example):
4. Factorial of a Number
Output (Example):
5. Fibonacci Series
Output (Example):
Why Learn C?
- C is the foundation for many modern programming languages like C++, Java, and Python.
- It teaches essential programming concepts like loops, conditionals, and memory management.
- Its versatility and speed make it ideal for system-level programming and performance-critical applications.