0% found this document useful (0 votes)
3 views2 pages

C Programming Exam Notes

The document provides an overview of C programming, including its history, components of a computer system, algorithms, and flowcharts. It covers essential programming concepts such as keywords, data types, operators, control structures, and functions. The document emphasizes the modularity and efficiency of C, making it suitable for various applications in system programming and embedded systems.

Uploaded by

Jaishree Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

C Programming Exam Notes

The document provides an overview of C programming, including its history, components of a computer system, algorithms, and flowcharts. It covers essential programming concepts such as keywords, data types, operators, control structures, and functions. The document emphasizes the modularity and efficiency of C, making it suitable for various applications in system programming and embedded systems.

Uploaded by

Jaishree Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Introduction to C Programming
C is a structured, procedural, and compiled programming language developed by Dennis Ritchie in
1972. It allows low-level memory access, making it efficient and widely used in system
programming, embedded systems, and applications. C follows the top-down approach and uses
functions to divide programs into smaller parts.

2. Components of a Computer System


A computer system consists of: - **Input Unit:** Keyboard, Mouse. - **Processing Unit (CPU):**
Includes Arithmetic Logic Unit (ALU) and Control Unit. - **Memory Unit:** RAM (temporary) and
ROM (permanent). - **Output Unit:** Monitor, Printer. - **Storage:** Hard Disk, Pen Drive.

3. Algorithms and Flowcharts


An algorithm is a step-by-step procedure to solve a problem, while a flowchart visually represents it
using symbols. - Oval: Start/Stop - Parallelogram: Input/Output - Rectangle: Process - Diamond:
Decision

4. Keywords, Identifiers, Constants, and Variables


Keywords are reserved words (like int, float, return). Identifiers are names given to variables or
functions. Constants hold fixed values, while variables are named memory locations whose values
can change during execution.

5. Data Types and Operators


C provides data types such as int, float, char, double, and void. Operators include: - Arithmetic (+, -,
*, /, %) - Relational (<, >, <=, >=, ==, !=) - Logical (&&, ||, !) - Assignment (=, +=, -=) -
Increment/Decrement (++/--) Operator precedence determines the order of evaluation: () > * / % > +
- > Relational > Logical > Assignment.

6. Preprocessor Directives and Header Files


Preprocessor directives (beginning with #) are processed before compilation. Common directives
include: - #include – for input/output functions - #include – for mathematical functions - #include –
for string functions Header files contain declarations of library functions used in C programs.

7. Control Structures
Control structures guide program flow and include conditional and looping statements. **Conditional
Statements:** - if: Executes a block when condition is true. - if-else: Executes one block if true,
another if false. - Nested if: if inside another if. - else-if Ladder: Checks multiple conditions
sequentially. - switch: Selects one case among many options. **Looping Statements:** - for loop:
Executes a block multiple times with initialization, condition, and increment. - while loop: Checks
condition before execution. - do-while loop: Executes once, then checks condition. **Jump
Statements:** break (exit loop), continue (skip iteration), goto (jump to label).

8. Functions in C
Functions make code modular and reusable. They are defined as: return_type
function_name(parameters) { // body } **Four Types of Functions:** 1. Without arguments, without
return value: void greet() { printf("Hello"); } 2. With arguments, without return value: void sum(int a,
int b) { printf("%d", a+b); } 3. Without arguments, with return value: int getValue() { return 5; } 4. With
arguments, with return value: int add(int a, int b) { return a+b; } **Other Concepts:** - Function
Prototype: Declaration before main(), e.g., int add(int, int); - Function Call: add(3,4); - Call by Value:
Passes a copy of variable (original unchanged). - Call by Reference: Passes address (original
changes). - Recursive Function: Function calls itself, e.g. factorial or Fibonacci.

You might also like