# CONSTANTES

Las constantes son valores fijos que el programa no puede alterar durante la ejecucion. Estos valores fijos tambien se denominan literales.

## Literales Enteros

Un literal entero puede ser una constante decimal, octal o hexadecimal. Un prefijo especifica la base o raiz: 0x o 0X para decimal, 0 para octal y nada para decimal.

## Definicion de Constantes

Hay dos formas de definir constantes:

* Usando #define preprocesador.
* Usando la palabra clave const.

### #define&#x20;

A constinuacion se muestra el formulario para usara #define para definir:

```c
#define identificador valor
```

Veamos un ejemplo:

```c
#include <stdio.h>

#define LENGTH 10
#define WIDTH 5
#define NEWLINE '\n'

int main() {
    
    int area;
    
    area = LENGHT * WIDTH;
    printf("Valor de area: %d, area");
    printf("%C", NEWLINE);
    
    return 0;
}
```

## Const

Se puede usar el prefijo para declarar constantes con un tipo especifico de la siguiente manera:

```c
const type variable = valor;
```

Veamos un ejemplo:

```c
#include <stdio.h>

int main() {
    const int LENGTH = 10;
    const int WIDTH = 5;
    const char NEWLINE = '\n';
    int area;
    
    area = LENGHT * WIDTH;
    printf("Valor de area : %d", area);
    printf("%c", NEWLINE);
    
    return 0;
}
```

Es buena practica definir constantes en mayusculas.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bla0x1s-organization.gitbook.io/untitled-1/reverse-engineering/c-programming/constantes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
