Fundamentals_of_Sequential_Programming
Fundamentals_of_Sequential_Programming
1. Basics of Programming
What is Programming?
Programming is the process of writing instructions (code) that a computer can understand and
execute.
Example (C Programming):
#include <stdio.h>
int main() {
printf("Hello, World!\n"); // Prints text to the screen
return 0;
}
Example:
int age = 20; // Integer variable
float pi = 3.14; // Floating-point number
char grade = 'A'; // Character
Operators in Programming
Operators are symbols that perform operations on variables and values.
Types of Operators
1. Arithmetic Operators: +, -, *, /, %
2. Relational Operators: ==, !=, <, >, <=, >=
3. Logical Operators: && (AND), || (OR), ! (NOT)
Example:
int a = 10, b = 5;
int sum = a + b; // sum = 15
int result = (a > b) && (b < 10); // result = 1 (true)
If-Else Statement:
int number = 10;
if (number > 0) {
printf("Positive number");
} else {
printf("Negative number or zero");
}
For Loop (Used when you know how many times to loop):
for(int i = 1; i <= 5; i++) {
printf("%d ", i);
}
Output: 1 2 3 4 5