Programming Basics Extended
Programming Basics Extended
2. Loops
Loops are control flow statements that allow a block of code to be executed repeatedly
based on a condition. They reduce the redundancy of writing the same code multiple times.
Syntax:
i = 0;
while (i < 5) {
printf("%d", i);
i++;
}
Example Output: 0 1 2 3 4
Syntax:
Example Output: 0 1 2 3 4
Syntax:
int n = 3;
do {
printf("%d", n);
n--;
} while (n >= 0);
Example Output: 3 2 1 0
3. Indentation
Proper indentation is essential for code readability. It visually separates different blocks of
code, making it easier to understand the program flow.
4. Data Types
Data Type Description Memory
5. Arrays
An array is a collection of elements, all of the same data type, stored in contiguous memory
locations. Each element can be accessed using its index.
Example:
Function Description
Example:
s = "mango"
print(s.title()) # Output: Mango