C Programming Quick Exam Notes
Simple point-wise notes for quick revision before exam.
1. Introduction to C
• C is a procedural programming language.
• Developed by Dennis Ritchie.
• C is fast, efficient, and portable.
• Used in operating systems, embedded systems, and software development.
2. Structure of a C Program
• Documentation Section – comments about program.
• Header Files – included using #include.
• main() function – execution starts here.
• Variable Declaration – stores data.
• Statements and Logic – actual program code.
• return 0 – indicates successful execution.
3. Data Types
• int – stores integers.
• float – stores decimal values.
• char – stores single character.
• double – stores large decimal values.
• void – represents no value.
4. Variables and Constants
• Variable stores changing data.
• Constant stores fixed value.
• Variables must be declared before use.
• const keyword is used for constants.
5. Input and Output Functions
• printf() is used to display output.
• scanf() is used to take input.
• %d for int, %f for float, %c for char.
• Escape sequences: \n, \t, \b.
6. Operators
• Arithmetic Operators: +, -, *, /, %.
• Relational Operators: ==, !=, >, <.
• Logical Operators: &&, ||, !.
• Assignment Operator: =.
• Increment and Decrement: ++, --.
7. Decision Making Statements
• if statement checks condition.
• if-else provides alternative execution.
• nested if is if inside another if.
• switch statement is used for multiple choices.
8. Looping Statements
• for loop – fixed number of repetitions.
• while loop – checks condition before execution.
• do-while loop – executes at least once.
• break exits loop.
• continue skips current iteration.
9. Arrays
• Array stores multiple values of same type.
• Array index starts from 0.
• Single-dimensional and multi-dimensional arrays are available.
• Example: int a[5];
10. Strings
• String is collection of characters.
• Stored using char array.
• Ends with null character \0.
• Functions: strlen(), strcpy(), strcat(), strcmp().
11. Functions
• Function is block of reusable code.
• Function improves modularity.
• Types: library functions and user-defined functions.
• Function can have arguments and return value.
12. Recursion
• Recursion means function calling itself.
• Used for factorial, Fibonacci, tree traversal.
• Must contain stopping condition.
13. Pointers
• Pointer stores address of variable.
• & operator gives address.
• * operator accesses value at address.
• Pointers improve memory handling.
14. Structures and Unions
• Structure stores different data types together.
• Declared using struct keyword.
• Union shares same memory among members.
• Structures use separate memory for members.
15. File Handling
• Files are used for permanent storage.
• fopen() opens file.
• fprintf() writes into file.
• fscanf() reads from file.
• fclose() closes file.
16. Dynamic Memory Allocation
• Memory allocated during runtime.
• malloc() allocates memory.
• calloc() allocates multiple blocks.
• free() releases memory.
17. Storage Classes
• auto – default local variable.
• register – stores variable in CPU register.
• static – retains value between function calls.
• extern – accesses global variable from another file.
18. Preprocessor Directives
• #include includes header file.
• #define creates macro.
• #ifdef checks condition during compilation.
19. Advantages of C
• Fast execution speed.
• Simple and flexible.
• Supports low-level programming.
• Widely used in software development.
20. Important Viva Points
• Execution starts from main() function.
• Every statement ends with semicolon.
• Compiler converts source code into machine code.
• Interpreter executes line by line.
• C is case-sensitive language.
Exam Tip: Write definitions first, then syntax/example, then advantages if needed.