1.
Loops in C Programming Loops allow repeated execution
of a block of code until a condition is met. They are
fundamental in writing efficient programs. Types of Loops:
While Loop: Checks condition first, executes only if true.
Do-While Loop: Executes once before checking condition.
For Loop: Best for known number of iterations. Example of
While Loop: #include <stdio.h> int main() { int i = 1; while (i
<= 10) { printf("%d\n", i); i++; } return 0; } This prints numbers
from 1 to 10. Notice that the loop continues until i <= 10
becomes false. Loops are also used for traversing arrays,
reading input repeatedly, and building patterns.
2. Functions in C Functions divide programs into smaller,
reusable modules. They make programs easier to
understand, test, and maintain. Why Functions? Code
reusability Improved readability Modularity for large programs
Structure of a Function: returnType
functionName(parameters) { // body } Example: #include
<stdio.h> int square(int n) { return n * n; } int main() {
printf("Square of 6 = %d", square(6)); return 0; } Functions can
be library functions like printf(), or user-defined. They may
also use recursion, where a function calls itself.
3. Arrays and Strings Arrays are collections of similar data
items stored at contiguous memory locations. Strings are
arrays of characters. Example: Array #include <stdio.h> int
main() { int arr[5] = {10, 20, 30, 40, 50}; for (int i = 0; i < 5; i++)
{ printf("%d ", arr[i]); } return 0; } Two-Dimensional Arrays:
Used to represent matrices or tables. Strings: #include
<stdio.h> #include <string.h> int main() { char str[20] =
"Hello"; printf("Length = %lu", strlen(str)); return 0; } Common
string functions are strlen, strcpy, strcmp, and strcat.
Arrays and strings are heavily used in data storage, input
handling, and algorithms.