Fundamentals of C
Fundamentals of C
1. Introduction
C is a general-purpose, procedural programming language developed by Dennis Ritchie in
1972 at Bell Labs. It is widely used for system programming, embedded systems, and
application development.
2. Basics of C
C programs use alphabets (A-Z, a-z), digits (0-9), and special symbols (+, -, *, /, %, { }, ; etc.).
The smallest units in a C program include:
3. Structure of a C Program
A basic C program consists of:
Example:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
4. Data Types in C
C has different data types categorized as:
5. Operators in C
Operators perform operations on variables and values. Some important types are:
• Arithmetic Operators: +, -, *, /, %
6. Control Statements
Control flow determines the execution sequence of a program.
Conditional Statements:
Example of if-else statement:
if (a > b) {
printf("A is greater");
} else {
printf("B is greater");
}
Looping Statements:
Example of for loop:
7. Functions in C
Functions help in reusing code. Example:
9. Pointers in C
Pointers store memory addresses. Example:
int a = 10;
int *ptr = &a;
printf("%d", *ptr); // Output: 10