C Programming Language – Complete Notes
(Exam Oriented)
1. Introduction to C Language
C is a structured, procedural programming language developed by Dennis Ritchie in 1972 at Bell Labs.
Features of C
• Simple and efficient
• Structured language
• Portable
• Middle-level language
• Rich library support
Applications of C
• Operating systems
• Embedded systems
• System programming
• Compiler design
2. Structure of a C Program
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
Explanation
• #include : Header file
• stdio.h : Standard input-output library
• main() : Entry point of program
3. Tokens in C
• Keywords
1
• Identifiers
• Constants
• Operators
• Special symbols
4. Data Types in C
Basic Data Types
• int
• float
• double
• char
Derived Data Types
• Array
• Pointer
• Function
User-defined Data Types
• struct
• union
• enum
• typedef
5. Variables and Constants
• Variable: Stores data
• Constant: Fixed value ( const keyword)
6. Operators in C
Types of Operators
• Arithmetic
• Relational
• Logical
• Assignment
• Increment / Decrement
• Bitwise
• Conditional (?:)
2
7. Input and Output Functions
• scanf()
• printf()
• getchar()
• putchar()
8. Control Statements
Decision Making
• if
• if-else
• switch
Looping Statements
• for
• while
• do-while
9. Functions in C
Types of Functions
• Library functions
• User-defined functions
Function Arguments
• Call by value
• Call by reference
10. Arrays
• One-dimensional arrays
• Two-dimensional arrays
Example:
3
int a[5] = {1,2,3,4,5};
11. Strings
• Character array
• String handling functions ( strlen , strcpy , strcmp )
12. Pointers
• Pointer declaration
• Pointer arithmetic
• Pointer to pointer
13. Structures
struct Student {
int roll;
char name[20];
};
14. Unions
• Memory sharing
• Only one member at a time
15. Enumerations
• User-defined data type
• Improves code readability
16. Storage Classes
• auto
• static
• extern
4
• register
17. Dynamic Memory Allocation
• malloc()
• calloc()
• realloc()
• free()
18. File Handling in C
File Functions
• fopen()
• fclose()
• fprintf()
• fscanf()
• fread()
• fwrite()
19. Preprocessor Directives
• #define
• #include
• #ifdef
• #ifndef
20. Command Line Arguments
• argc
• argv
21. Recursion
• Function calling itself
5
22. Advantages of C
• Fast execution
• Portable
• Easy to learn
23. Disadvantages of C
• No object-oriented features
• No automatic garbage collection
24. Summary
C is a powerful language that forms the foundation for many modern programming languages.
These notes are ideal for [Link] / Diploma / University Semester Exams.