Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 8, 2019 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e0dbde18a7c161a55208627615a834cf to your computer and use it in GitHub Desktop.
Save parzibyte/e0dbde18a7c161a55208627615a834cf to your computer and use it in GitHub Desktop.
/*
Tablas de multiplicar en C
https://parzibyte.me/blog
*/
#include <stdio.h>
// Definimos el prototipo de la función
void tablaDeMultiplicar(int numeroDeTabla);
int main(void) {
int numeroDeTabla = 7; // Ejemplo con la tabla del 7
tablaDeMultiplicar(numeroDeTabla);
/*Salida:
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70
*/
}
// Ahora sí definimos la función
void tablaDeMultiplicar(int numeroDeTabla) {
// Ciclo for del 1 al 10
for (int x = 1; x <= 10; x++) {
int resultado = x * numeroDeTabla;
// Cada %d representa un valor que será remplazado
printf("%d x %d = %d\n", numeroDeTabla, x, resultado);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment