๐ป C Programming
Learn C programming from the basics with simple explanations, examples, diagrams, important concepts and exam-friendly notes.
๐ C Programming Topics
๐ป 1. Introduction to C
C is a general-purpose, procedural programming language. It is widely used for system programming, embedded systems and application development.
โญ Basic C Program
๐ Important Parts
- ๐ #include <stdio.h> โ Includes the standard input/output header.
- ๐ main() โ Starting point of the program.
- ๐จ๏ธ printf() โ Displays output.
- โ return 0; โ Indicates successful program termination.
๐ฆ 2. Variables & Data Types
A variable is a named memory location used to store data.
๐ข Common C Data Types
Integer values
Decimal values
More precise decimal values
Single character
int age = 20; stores the integer value 20 in the variable named age.
โ 3. Operators
Operators are symbols used to perform operations on values and variables.
โ Arithmetic
+ - * / %
๐ Relational
> < == != >= <=
๐ง Logical
&& || !
๐ Assignment
= += -= *=
๐ 4. if-else
The if-else statement is used to make decisions based on a condition.
๐ 5. switch Statement
The switch statement is used when one expression needs to be compared with multiple possible values.
The break statement is commonly used to exit a case.
๐ 6. Loops
Loops are used to execute a block of statements repeatedly.
๐ for Loop
Useful when the number of repetitions is known.
๐ while Loop
Checks the condition before execution.
๐ do-while Loop
Executes the body at least once.
โ๏ธ 7. Functions
A function is a block of code designed to perform a particular task.
โจ Advantages
- โป๏ธ Code reusability
- ๐งน Reduces repetition
- ๐ Improves readability
- ๐ ๏ธ Easier maintenance
๐ 8. Arrays
An array stores multiple values of the same data type in a contiguous collection.
C array indexing starts from 0.
๐ค 9. Strings
In C, a string is a sequence of characters stored in a character array and terminated by the null character \0.
๐ป String Example๐งฐ Common String Functions
Finds string length
Joins strings
Copies a string
Compares strings
๐ 10. Pointers
A pointer is a variable that stores the memory address of another variable.
value = 10
& โ address-of operator
* โ dereference operator
๐๏ธ 11. Structures
A structure is a user-defined data type that allows different types of data to be grouped together.
๐ป Structure Example๐ Example Structure
๐ 12. File Handling
File handling allows a C program to store and retrieve data from files.
๐งฐ Common File Functions
๐ C Programming Quick Revision
- ๐ป C โ General-purpose procedural language
- ๐ฆ Variable โ Stores data
- ๐ข Data Type โ Defines type of data
- โ Operator โ Performs operations
- ๐ if-else โ Decision making
- ๐ switch โ Multiple choices
- ๐ Loop โ Repeated execution
- โ๏ธ Function โ Reusable block of code
- ๐ Array โ Collection of same-type elements
- ๐ค String โ Character sequence
- ๐ Pointer โ Stores an address
- ๐๏ธ Structure โ Groups different data types
- ๐ File Handling โ Read/write files
๐ฏ BCA C Programming Exam Checklist
Before your exam, make sure you have revised these important topics: