About the C Programming Language

Overview

C is a powerful and popular programming language known for its efficiency, flexibility, and portability. Developed in the early 1970s by Dennis Ritchie at Bell Labs, C has been influential in the development of many other programming languages.

Example: Hello World

Here's a simple "Hello, World!" program in C:

#include <stdio.h>

int main() {
    printf("Hello, World!\\n");
    return 0;
}

Example: Variables and Operations

Example demonstrating basic variable declaration and arithmetic operations:

#include <stdio.h>

int main() {
    int a = 10, b = 5;
    int sum = a + b;
    int product = a * b;

    printf("Sum: %d\\n", sum);
    printf("Product: %d\\n", product);

    return 0;
}

Arrays and Pointers

Exploring arrays and pointers in C:

#include <stdio.h>

int main() {
    int numbers[] = {1, 2, 3, 4, 5};
    int *ptr = numbers;

    printf("First element: %d\\n", *ptr);
    printf("Second element: %d\\n", *(ptr + 1));

    return 0;
}

Conditional Statements

Using conditional statements in C:

#include <stdio.h>

int main() {
    int number = 10;

    if (number > 0) {
        printf("The number is positive.\\n");
    } else {
        printf("The number is not positive.\\n");
    }

    return 0;
}

Functions

Creating and using functions in C:

#include <stdio.h>

// Function declaration
int add(int a, int b) {
    return a + b;
}

int main() {
    int result = add(5, 3);
    printf("Sum: %d\\n", result);

    return 0;
}