Comandos de C nivel de clase
|
bool
|
1 bit
|
|
int
|
4 byte
|
|
short
|
2 byte
|
|
float
|
4 byte
|
|
double
|
8 byte
|
|
long double
|
16 byte
|
|
char
|
1 byte
|
|
=
|
Asignación
|
&
|
AND (registro)
|
|
+
|
Suma
|
|
|
OR (registro)
|
|
-
|
Resta
|
^
|
XOR (registro)
|
|
*
|
Multiplicación
|
~
|
NOT (registro)
|
|
/
|
División
|
<<
|
Desplaz. bit izq
|
|
%
|
Módulo
|
>>
|
Desplaz. bit der
|
|
void nombre () {}
|
|
Estas funciones NO devuelven valores, podemos verlas como un simple bloque de código que podemos repetir haciendo diversas llamadas
|
|
tipo_de_dato nombre () {}
|
|
Estas funciones SI devuelven valores, pueden ser de cualquier tipo (int, char, float ...). Su principal diferencia es que cuando hacemos las llamadas a dichas funciones en esa llamada tendremos un valor. ¿Qué valor? el que pongamos el return. ES OBLIGATORIO el return
|
|
Estructura de función
|
|
Al declarar una función podemos hacerlo bien sin parámetros paréntesis vacios, o bien podemos pasarle parámetros, los cuales necesitamos rellenar en la llamada paréntesis (tipo_dato nombre) podemos poner tantos parámetros como quedamos
|
|
==
|
Igual a
|
!=
|
Distinto
|
|
<
|
Menor
|
>
|
Mayor
|
|
<=
|
Menor igual
|
>=
|
Mayor igual
|
|
&&
|
AND (lógico) Y
|
||
|
OR (lógico) O
|
|
!
|
NOT
|
||
|
Escribir texto
|
printf("texto");
|
|
Escribir int
|
printf("texto %i", variable_int);
|
|
Escribir float
|
printf("texto %f", variable_float);
|
|
Escribir double
|
printf("texto %d", variable_double);
|
|
Escribir caracter
|
printf("texto %c", variable_char);
|
|
Leer entero
|
scanf("%i", &variable_almacen_int);
|
|
Leer float
|
scanf("%f", &variable_almacen_float);
|
|
Leer double
|
scanf("%d", &variable_almacen_double);
|
|
Leer caracter
|
scanf("%c", &variable_almacen_char);
|
|
Num aleatorio
|
rand()%numero_limite
|
|
Num aleatorio rango
|
(rand()%(M-m+1)+m)
|
|
Modificar seed
|
srand(time(NUL))
|
for(int i=**punto_inicio**; i<=**limite_elementos**; i++){
for(int j=**punto_inicio**; j<=**limite_elementos**; j++){
printf("%i \t", vector[i][j]);
}
}
for(int i=**punto_inicio**; i<=**limite_elementos**; i++){
printf("%i \t", vector[i]);
}
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.