# stdint

***

1. **Counting elements in an array:**

```cpp
#include <stdint.h>

int main() {
  int64_t arr[] = {1, 2, 3, 4, 5};
  size_t size = sizeof(arr) / sizeof(arr[0]);

  int64_t count = 0;
  for (size_t i = 0; i < size; ++i) {
    if (arr[i] > 0) {
      ++count;
    }
  }

  printf("Number of positive elements: %ld\n", count);
  return 0;
}
```

2. **Calculating the sum of an array:**

```cpp
#include <stdint.h>

int main() {
  int64_t arr[] = {1, 2, 3, 4, 5};
  size_t size = sizeof(arr) / sizeof(arr[0]);

  int64_t sum = 0;
  for (size_t i = 0; i < size; ++i) {
    sum += arr[i];
  }

  printf("Sum of the array: %ld\n", sum);
  return 0;
}
```

3. **Finding the maximum element in an array:**

```cpp
#include <stdint.h>

int main() {
  int64_t arr[] = {1, 2, 3, 4, 5};
  size_t size = sizeof(arr) / sizeof(arr[0]);

  int64_t max = arr[0];
  for (size_t i = 1; i < size; ++i) {
    if (arr[i] > max) {
      max = arr[i];
    }
  }

  printf("Maximum element in the array: %ld\n", max);
  return 0;
}
```

4. **Finding the minimum element in an array:**

```cpp
#include <stdint.h>

int main() {
  int64_t arr[] = {1, 2, 3, 4, 5};
  size_t size = sizeof(arr) / sizeof(arr[0]);

  int64_t min = arr[0];
  for (size_t i = 1; i < size; ++i) {
    if (arr[i] < min) {
      min = arr[i];
    }
  }

  printf("Minimum element in the array: %ld\n", min);
  return 0;
}
```

5. **Converting a string to an integer:**

```cpp
#include <stdint.h>
#include <stdlib.h>

int main() {
  char *str = "123";

  int64_t num = strtol(str, NULL, 10);

  printf("Integer value: %ld\n", num);
  return 0;
}
```

6. **Converting an integer to a string:**

```cpp
#include <stdint.h>
#include <stdio.h>

int main() {
  int64_t num = 123;

  char str[100];
  sprintf(str, "%ld", num);

  printf("String value: %s\n", str);
  return 0;
}
```

7. **Reading a file:**

```cpp
#include <stdint.h>
#include <stdio.h>

int main() {
  FILE *fp = fopen("file.txt", "r");

  char buf[1024];
  while (fgets(buf, sizeof(buf), fp) != NULL) {
    printf("%s", buf);
  }

  fclose(fp);
  return 0;
}
```

8. **Writing to a file:**

```cpp
#include <stdint.h>
#include <stdio.h>

int main() {
  FILE *fp = fopen("file.txt", "w");

  fprintf(fp, "Hello world!\n");

  fclose(fp);
  return 0;
}
```

9. **Creating a linked list:**

```cpp
#include <stdint.h>
#include <stdlib.h>

struct Node {
  int64_t data;
  struct Node *next;
};

int main() {
  struct Node *head = NULL;

  for (int64_t i = 0; i < 10; ++i) {
    struct Node *new_node = malloc(sizeof(struct Node));
    new_node->data = i;
    new_node->next = head;
    head = new_node;
  }

  struct Node *current = head;
  while (current != NULL) {
    printf("%ld ", current->data);
    current = current->next;
  }

  return 0;
}
```

10. **Creating a binary tree:**

```cpp
#include <stdint.h>
#include <stdlib.h>

struct Node {
  int64_t data;
  struct Node *left;
  struct Node *right;
};

int main() {
  struct Node *root = NULL;

  for (int64_t i = 0; i < 10; ++i) {
    struct Node *new_node = malloc(sizeof(struct Node));
    new_node->data = i;
    new_node->left = NULL;
    new_node->right = NULL;

    if (root == NULL) {
      root = new_node;
    } else {
      struct Node *current = root;
      while (1) {
        if (i < current->data) {
          if (current->left == NULL) {
            current->left = new_node;
            break;
          } else {
            current = current->left;
          }
        } else {
          if (current->right == NULL)

```
