Introduction to C Language
C is a general-purpose programming language created by Dennis Ritchie in 1972 at Bell
Labs. It was designed to develop system software like operating systems but is now
widely used for various applications.
Key Characteristics of C Language:
1. Simple and Efficient: Easy to write and understand with minimal syntax, yet powerful
for performance-critical applications.
2. Low-Level Access: Provides direct access to memory and hardware, making it ideal
for system programming.
, 2
3. Portable: Code written in C can run on different machines with minimal modifications.
4. Structured Language: Allows breaking down a program into modules or functions for
better readability and debugging.
5. Rich Library Support: Includes numerous built-in functions for input/output, string
manipulation, math operations, etc.
Applications of C:
Operating systems (e.g., Unix, Linux, Windows)
Embedded systems (used in IoT devices)
Compilers and interpreters
Game development
Database systems (e.g., MySQL)
, 3
---
C Programs
A C program typically consists of the following structure:
1. Preprocessor Directives: These include necessary libraries (like #include <stdio.h> for
input/output functions).
2. Main Function: The main() function is the entry point of every C program where
execution begins.
3. Program Body: Contains statements, variable declarations, and logic to perform the
desired task.
Basic C Program Structure:
#include <stdio.h> // Preprocessor directive for standard I/O library
, 4
// Main function
int main() {
printf("Hello, World!"); // Output statement
return 0; // Indicates program executed successfully
}
Explanation:
1. #include <stdio.h>: Includes the Standard Input/Output library to use functions like
printf() and scanf().
2. int main(): Defines the main function. It returns an integer value.
3. printf("Hello, World!");: Prints "Hello, World!" to the screen.
4. return 0;: Signals that the program has completed successfully.