- Get link
- X
- Other Apps
IMPORTANT THEORY NOTES
1. Introduction to C Programming
C is a high-level structured programming language.
It was developed by Dennis Ritchie in 1972 at AT&T Bell Laboratories.
C is used to develop system software, application software, and embedded systems.
2. Features of C Language
Simple and easy to learn
Structured and modular
Portable (machine independent)
Fast execution
Supports low-level programming
3. Structure of a C Program
Documentation section
Link section (
#include <stdio.h>)Definition section (
#define)Global declaration section
main()functionUser-defined functions
4. Keywords
Keywords are reserved words in C.
They have fixed meanings and cannot be used as identifiers.
Examples:
int,float,if,else,while,for,return
5. Variables
A variable is a named memory location used to store data.
The value of a variable can change during program execution.
Example:
int a;
6. Constants
Constants are fixed values that do not change during program execution.
Example:
#define PI 3.14
7. Data Types
Data types specify the type of data stored in a variable.
| Data Type | Description |
|---|---|
| int | Integer numbers |
| float | Decimal numbers |
| char | Single character |
| double | Large decimal numbers |
8. Operators
Operators are symbols used to perform operations.
Types of Operators:
Arithmetic:
+ - * / %Relational:
> < >= <= == !=Logical:
&& || !Assignment:
=
9. Input and Output Functions
scanf()is used to take input from the user.printf()is used to display output.
Example:
scanf("%d", &a);
printf("%d", a);
10. Format Specifiers
| Specifier | Meaning |
| %d | Integer |
| %f | Float |
| %c | Character |
| %s | String |
11. Decision Making Statements
Used to make decisions based on conditions.
ifif...elseelse if
12. Looping Statements
Loops are used to repeat statements.
Types of Loops:
forloopwhileloopdo...whileloop
13. Difference Between for and while Loop
| for loop | while loop |
| Iterations are known | Iterations are unknown |
| Initialization inside loop | Initialization outside loop |
14. Array
An array is a collection of similar data types.
It stores multiple values using a single variable name.
Example:
int a[5];
15. Function
A function is a block of code that performs a specific task.
It improves code reusability.
Types of Functions:
Library function
User-defined function
16. Header File
A header file contains function declarations.
Examples:
stdio.h,conio.h
17. Compiler
A compiler translates the whole program at once.
Errors are shown after compilation.
Example: GCC
18. Types of Errors
Syntax Error – Grammar mistake
Logical Error – Wrong output
Runtime Error – Occurs during execution
19. Comments
Comments are non-executable statements.
Used to explain the program.
Types:
Single-line comment:
//Multi-line comment:
/* */
20. Algorithm
An algorithm is a step-by-step procedure to solve a problem.
Characteristics: finite, definite, effective
EXAM WRITING TIPS
Write answers in points
Use keywords from the question
Draw tables for differences
Underline important terms
- Get link
- X
- Other Apps
Comments
Post a Comment