SlideShare a Scribd company logo
1 of 3
Soluciones de la dirigida 5
#include<stdio.h>
int inicio(void); // Prototipo de la funcin universo
int muestra(int n); // Prototipo de la funcin muestra
int combinatoria(int n, int k); // Prototipo de la funcin combinatoria
int main()
{
int n,k;
n = inicio();
k = muestra(n);
printf("El n'umero de combinaciones de %d
elemento(s) de %d elemento(s) dado(s) es %dn",k,n,combinatoria(n,k));
}
int inicio(void) // cabecera de la definicin universo
{
int ok = 0;
int n; // variable donde almacenar'e lo que voy a retornar
printf("Ingrese un entero positivo: ");
scanf("%d",&n);
return n;
}
int muestra(int n) // cabecera de la definicin de la funci'on muestra
{
int ok = 0;
int k; // variable donde almacenar'e lo que voy a retornar
printf("Ingrese un entero positivo menor o igual a %d: ",n);
scanf("%d",&k);
return k;
}
int combinatoria(int n, int k) // cabecera de la definicin de la funcin
combinatoria
{
if (k == 1)
return n;
else
if (n == k)
return 1;
else
return combinatoria(n-1,k-1) + combinatoria(n-1,k);
}
#include<stdio.h>
int ingresar(void); // Prototipo de la funcin ingresar
int fibo(int n); // Prototipo de la funcin fibo
void main()
{
int n;
n = ingresar();
printf(" F(%d) = %d.nn", n, fibo(n));
}
int ingresar(void) // cabecera de la definicin de la funci'on exponente
{
int n; // variable donde almacenar'e lo que voy a retornar
printf("n Ingrese el exponente (n'umero entero): ");
scanf("%d",&n);
return n;
}
int fibo(int n) // cabecera de la definicin de la funcin fibo
{
if ( n <= 2 )
return 1; // fibo(1) = fibo (2) = 1
else
return fibo(n-1) + fibo(n-2); // fibo(n) = fibo(n-1) + fibo(n-2)
}
#include<stdio.h>
float base(void); // Prototipo de la funcin base
int exponente(void); // Prototipo de la funcin exponente
float potencia(float b, int n); // Prototipo de la funcin potencia
int main()
{
float b;
int n;
b = base();
n = exponente();
printf("%f elevado a la %d es igual a %fn",b,n,potencia(b,n));
}
float base(void) // cabecera de la definicin base
{
int ok = 0;
float b; // variable donde almacenar'e lo que voy a retornar
printf("Ingrese la base (n'umero positivo): ");
scanf("%f",&b);
return b;
}
int exponente(void) // cabecera de la definicin de la funci'on exponente
{
int n; // variable donde almacenar'e lo que voy a retornar
printf("Ingrese el exponente (n'umero entero): ");
scanf("%d",&n);
return n;
}
float potencia(float b, int n) // cabecera de la definicin de la funcin potencia
{
float retorno = 1;
if ( n > 0 )
retorno = b*potencia(b,n-1);
if ( n < 0 )
retorno = potencia(b,n+1)/b;
return retorno;
}
/*
* Un programa en C para encontrar el MCD de dos
numeros usando recursion
*/
#include <stdio.h>
int gcd(int, int);
int main()
{
int a, b, resultado;
printf(" Ingresa dos numeros para encontrar el MCD:");
scanf("%d%d", &a, &b);
resultado = mcd(a, b);
printf("El MCD DE %d y %d es %d.n", a, b, resultado);
}
int mcd(int a, int b)
{
while (a != b)
{
if (a > b)
{
return mcd(a - b, b);
}
else
{
return mcd(a, b - a);
}
}
return a;
}
/*
* Un programa para revertir un numero
*/
#include <stdio.h>
#include <math.h>
int rev(int, int);
int main()
{
int num, resultado;
int longitud = 0, temp;
printf("Ingresar un numero entero para revertir: ");
scanf("%d", &num);
temp = num;
while (temp != 0)
{
longitud++;
temp = temp / 10;
}
resultado = rev(num, longitud);
printf("El reverso de %d es %d.n", num, resultado);
return 0;
}
int rev(int num, int len)
{
if (len == 1)
{
return num;
}
else
{
return (((num % 10) * pow(10, len - 1)) + rev(num / 10, --len));
}
}

More Related Content

What's hot

Serie Fibonacci en C
Serie Fibonacci en CSerie Fibonacci en C
Serie Fibonacci en C
Abraham
 
Pr106 funcionesdefinicion variables
Pr106 funcionesdefinicion variablesPr106 funcionesdefinicion variables
Pr106 funcionesdefinicion variables
yonatan novoa
 
Codificaciones c++
Codificaciones c++Codificaciones c++
Codificaciones c++
mario_10
 
Funcionesen codeblocks ejerciciosresueltos
Funcionesen codeblocks ejerciciosresueltosFuncionesen codeblocks ejerciciosresueltos
Funcionesen codeblocks ejerciciosresueltos
germancat77
 
Ejemplos recursividad.docx
Ejemplos recursividad.docxEjemplos recursividad.docx
Ejemplos recursividad.docx
KevinPeaChavez
 
Computacion punteros
Computacion punterosComputacion punteros
Computacion punteros
Manuel
 
Para contar la cantidad de digitos
Para contar la cantidad de digitosPara contar la cantidad de digitos
Para contar la cantidad de digitos
jbersosa
 
50 Php. Funciones Que Devuelven Valores
50 Php. Funciones Que Devuelven Valores50 Php. Funciones Que Devuelven Valores
50 Php. Funciones Que Devuelven Valores
José M. Padilla
 

What's hot (19)

Presentación 13 Paso por referencia
Presentación 13 Paso por referenciaPresentación 13 Paso por referencia
Presentación 13 Paso por referencia
 
Serie Fibonacci en C
Serie Fibonacci en CSerie Fibonacci en C
Serie Fibonacci en C
 
Practca#1 2210
Practca#1 2210 Practca#1 2210
Practca#1 2210
 
Ejemplos c++
Ejemplos c++Ejemplos c++
Ejemplos c++
 
Pr106 funcionesdefinicion variables
Pr106 funcionesdefinicion variablesPr106 funcionesdefinicion variables
Pr106 funcionesdefinicion variables
 
Presentación 09 Cajas blanca
Presentación 09 Cajas blancaPresentación 09 Cajas blanca
Presentación 09 Cajas blanca
 
Ejercicios resueltos en el Laboratorio de estructuras secuenciales
Ejercicios resueltos en el Laboratorio de  estructuras secuencialesEjercicios resueltos en el Laboratorio de  estructuras secuenciales
Ejercicios resueltos en el Laboratorio de estructuras secuenciales
 
Codificaciones c++
Codificaciones c++Codificaciones c++
Codificaciones c++
 
Hp
HpHp
Hp
 
Laboratorio1 entrada-salida de datos / Lenguance C
Laboratorio1   entrada-salida de datos / Lenguance CLaboratorio1   entrada-salida de datos / Lenguance C
Laboratorio1 entrada-salida de datos / Lenguance C
 
Funcionesen codeblocks ejerciciosresueltos
Funcionesen codeblocks ejerciciosresueltosFuncionesen codeblocks ejerciciosresueltos
Funcionesen codeblocks ejerciciosresueltos
 
Ejemplos recursividad.docx
Ejemplos recursividad.docxEjemplos recursividad.docx
Ejemplos recursividad.docx
 
Computacion punteros
Computacion punterosComputacion punteros
Computacion punteros
 
Unidad 2 informe tecnico
Unidad 2 informe tecnicoUnidad 2 informe tecnico
Unidad 2 informe tecnico
 
Programa en c de listas
Programa en c de listasPrograma en c de listas
Programa en c de listas
 
Presentación1
Presentación1Presentación1
Presentación1
 
Para contar la cantidad de digitos
Para contar la cantidad de digitosPara contar la cantidad de digitos
Para contar la cantidad de digitos
 
50 Php. Funciones Que Devuelven Valores
50 Php. Funciones Que Devuelven Valores50 Php. Funciones Que Devuelven Valores
50 Php. Funciones Que Devuelven Valores
 
El lenguaje c
El lenguaje cEl lenguaje c
El lenguaje c
 

Viewers also liked

вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011
вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011
вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011
Иван Иванов
 
PINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZ
PINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZPINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZ
PINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZ
JUAN DIEGO
 

Viewers also liked (20)

10 boas razões para beber vinho
10 boas razões para beber vinho10 boas razões para beber vinho
10 boas razões para beber vinho
 
General resume
General resumeGeneral resume
General resume
 
Holyweekandeasterfamouspaintings 160323172653
Holyweekandeasterfamouspaintings 160323172653Holyweekandeasterfamouspaintings 160323172653
Holyweekandeasterfamouspaintings 160323172653
 
Katalog UNIQ parfémů
Katalog UNIQ parfémůKatalog UNIQ parfémů
Katalog UNIQ parfémů
 
CV_Csilla_Nemeth
CV_Csilla_NemethCV_Csilla_Nemeth
CV_Csilla_Nemeth
 
B2B Buyer Journey and Content Marketing
B2B Buyer Journey and Content Marketing B2B Buyer Journey and Content Marketing
B2B Buyer Journey and Content Marketing
 
Twitter for Business
Twitter for BusinessTwitter for Business
Twitter for Business
 
090820 Regional Forum Ppt English Haesco
090820 Regional Forum Ppt English   Haesco090820 Regional Forum Ppt English   Haesco
090820 Regional Forum Ppt English Haesco
 
вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011
вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011
вестник южно уральского-государственного_университета._серия_лингвистика_№2_2011
 
Duel-Audience-Engagement-Platform
Duel-Audience-Engagement-PlatformDuel-Audience-Engagement-Platform
Duel-Audience-Engagement-Platform
 
Podcast ( diana campozano)
Podcast ( diana campozano)Podcast ( diana campozano)
Podcast ( diana campozano)
 
Missing the Mark: Global Content Survey of Brand Marketers and their B2B Audi...
Missing the Mark: Global Content Survey of Brand Marketers and their B2B Audi...Missing the Mark: Global Content Survey of Brand Marketers and their B2B Audi...
Missing the Mark: Global Content Survey of Brand Marketers and their B2B Audi...
 
VELÁZQUEZ, Diego Rodriguez de Silva y, Featured Paintings in Detail (1)
VELÁZQUEZ, Diego Rodriguez de Silva y, Featured Paintings in Detail (1)VELÁZQUEZ, Diego Rodriguez de Silva y, Featured Paintings in Detail (1)
VELÁZQUEZ, Diego Rodriguez de Silva y, Featured Paintings in Detail (1)
 
Mr Polk's War
Mr Polk's WarMr Polk's War
Mr Polk's War
 
Pattonville model (REFRENSI)
Pattonville model (REFRENSI)Pattonville model (REFRENSI)
Pattonville model (REFRENSI)
 
VALIDASI REABILITAS NILAI TES
VALIDASI REABILITAS NILAI TESVALIDASI REABILITAS NILAI TES
VALIDASI REABILITAS NILAI TES
 
PINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZ
PINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZPINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZ
PINTURA BARROCA ESPAÑOLA (II): VELÁZQUEZ
 
Foreign Affairs Trouble the Nation
Foreign Affairs Trouble the NationForeign Affairs Trouble the Nation
Foreign Affairs Trouble the Nation
 
The American Legal System
The American Legal SystemThe American Legal System
The American Legal System
 
Thought leadership disrupted: New rules for the content age
Thought leadership disrupted: New rules for the content ageThought leadership disrupted: New rules for the content age
Thought leadership disrupted: New rules for the content age
 

Similar to PROBLEMAS DE PROGRAMACION 3

ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++
die_dex
 
ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++
die_dex
 
Capítulo 6 funciones y procedimiento
Capítulo 6 funciones y procedimientoCapítulo 6 funciones y procedimiento
Capítulo 6 funciones y procedimiento
EnAutomático
 

Similar to PROBLEMAS DE PROGRAMACION 3 (20)

ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++
 
Funciones en C
Funciones en CFunciones en C
Funciones en C
 
FUNCIONES LENGUAJE C
FUNCIONES LENGUAJE CFUNCIONES LENGUAJE C
FUNCIONES LENGUAJE C
 
PROBLEMAS DE POGRAMACION 1
PROBLEMAS DE POGRAMACION 1PROBLEMAS DE POGRAMACION 1
PROBLEMAS DE POGRAMACION 1
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Practicas de programacion 11 20
Practicas de programacion 11 20Practicas de programacion 11 20
Practicas de programacion 11 20
 
Operadores
OperadoresOperadores
Operadores
 
Operadores y expresiones
Operadores y expresionesOperadores y expresiones
Operadores y expresiones
 
Operadores
OperadoresOperadores
Operadores
 
11 Funciones
11 Funciones11 Funciones
11 Funciones
 
11funciones 1231096290787715-2
11funciones 1231096290787715-211funciones 1231096290787715-2
11funciones 1231096290787715-2
 
Funciones.ppt
Funciones.pptFunciones.ppt
Funciones.ppt
 
ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++
 
Mayor de 3 numeros con operacion
Mayor de 3 numeros con operacionMayor de 3 numeros con operacion
Mayor de 3 numeros con operacion
 
Capítulo 6 funciones y procedimiento
Capítulo 6 funciones y procedimientoCapítulo 6 funciones y procedimiento
Capítulo 6 funciones y procedimiento
 
Include
IncludeInclude
Include
 
Programación 1: funciones en C
Programación 1: funciones en CProgramación 1: funciones en C
Programación 1: funciones en C
 
Clase 6
Clase 6Clase 6
Clase 6
 

Recently uploaded

🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx
🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx
🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx
EliaHernndez7
 
2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx
2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx
2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx
RigoTito
 
Cuaderno de trabajo Matemática 3 tercer grado.pdf
Cuaderno de trabajo Matemática 3 tercer grado.pdfCuaderno de trabajo Matemática 3 tercer grado.pdf
Cuaderno de trabajo Matemática 3 tercer grado.pdf
NancyLoaa
 
Curso = Metodos Tecnicas y Modelos de Enseñanza.pdf
Curso = Metodos Tecnicas y Modelos de Enseñanza.pdfCurso = Metodos Tecnicas y Modelos de Enseñanza.pdf
Curso = Metodos Tecnicas y Modelos de Enseñanza.pdf
Francisco158360
 

Recently uploaded (20)

🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx
🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx
🦄💫4° SEM32 WORD PLANEACIÓN PROYECTOS DARUKEL 23-24.docx
 
Programacion Anual Matemática5 MPG 2024 Ccesa007.pdf
Programacion Anual Matemática5    MPG 2024  Ccesa007.pdfProgramacion Anual Matemática5    MPG 2024  Ccesa007.pdf
Programacion Anual Matemática5 MPG 2024 Ccesa007.pdf
 
Sesión de clase: Fe contra todo pronóstico
Sesión de clase: Fe contra todo pronósticoSesión de clase: Fe contra todo pronóstico
Sesión de clase: Fe contra todo pronóstico
 
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VSOCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
 
Power Point: Fe contra todo pronóstico.pptx
Power Point: Fe contra todo pronóstico.pptxPower Point: Fe contra todo pronóstico.pptx
Power Point: Fe contra todo pronóstico.pptx
 
2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx
2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx
2 REGLAMENTO RM 0912-2024 DE MODALIDADES DE GRADUACIÓN_.pptx
 
TIPOLOGÍA TEXTUAL- EXPOSICIÓN Y ARGUMENTACIÓN.pptx
TIPOLOGÍA TEXTUAL- EXPOSICIÓN Y ARGUMENTACIÓN.pptxTIPOLOGÍA TEXTUAL- EXPOSICIÓN Y ARGUMENTACIÓN.pptx
TIPOLOGÍA TEXTUAL- EXPOSICIÓN Y ARGUMENTACIÓN.pptx
 
Estrategia de prompts, primeras ideas para su construcción
Estrategia de prompts, primeras ideas para su construcciónEstrategia de prompts, primeras ideas para su construcción
Estrategia de prompts, primeras ideas para su construcción
 
SESION DE PERSONAL SOCIAL. La convivencia en familia 22-04-24 -.doc
SESION DE PERSONAL SOCIAL.  La convivencia en familia 22-04-24  -.docSESION DE PERSONAL SOCIAL.  La convivencia en familia 22-04-24  -.doc
SESION DE PERSONAL SOCIAL. La convivencia en familia 22-04-24 -.doc
 
2024 KIT DE HABILIDADES SOCIOEMOCIONALES.pdf
2024 KIT DE HABILIDADES SOCIOEMOCIONALES.pdf2024 KIT DE HABILIDADES SOCIOEMOCIONALES.pdf
2024 KIT DE HABILIDADES SOCIOEMOCIONALES.pdf
 
Unidad 3 | Metodología de la Investigación
Unidad 3 | Metodología de la InvestigaciónUnidad 3 | Metodología de la Investigación
Unidad 3 | Metodología de la Investigación
 
Cuaderno de trabajo Matemática 3 tercer grado.pdf
Cuaderno de trabajo Matemática 3 tercer grado.pdfCuaderno de trabajo Matemática 3 tercer grado.pdf
Cuaderno de trabajo Matemática 3 tercer grado.pdf
 
CALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADCALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDAD
 
LA LITERATURA DEL BARROCO 2023-2024pptx.pptx
LA LITERATURA DEL BARROCO 2023-2024pptx.pptxLA LITERATURA DEL BARROCO 2023-2024pptx.pptx
LA LITERATURA DEL BARROCO 2023-2024pptx.pptx
 
Curso = Metodos Tecnicas y Modelos de Enseñanza.pdf
Curso = Metodos Tecnicas y Modelos de Enseñanza.pdfCurso = Metodos Tecnicas y Modelos de Enseñanza.pdf
Curso = Metodos Tecnicas y Modelos de Enseñanza.pdf
 
Tema 8.- PROTECCION DE LOS SISTEMAS DE INFORMACIÓN.pdf
Tema 8.- PROTECCION DE LOS SISTEMAS DE INFORMACIÓN.pdfTema 8.- PROTECCION DE LOS SISTEMAS DE INFORMACIÓN.pdf
Tema 8.- PROTECCION DE LOS SISTEMAS DE INFORMACIÓN.pdf
 
Supuestos_prácticos_funciones.docx
Supuestos_prácticos_funciones.docxSupuestos_prácticos_funciones.docx
Supuestos_prácticos_funciones.docx
 
proyecto de mayo inicial 5 añitos aprender es bueno para tu niño
proyecto de mayo inicial 5 añitos aprender es bueno para tu niñoproyecto de mayo inicial 5 añitos aprender es bueno para tu niño
proyecto de mayo inicial 5 añitos aprender es bueno para tu niño
 
Prueba libre de Geografía para obtención título Bachillerato - 2024
Prueba libre de Geografía para obtención título Bachillerato - 2024Prueba libre de Geografía para obtención título Bachillerato - 2024
Prueba libre de Geografía para obtención título Bachillerato - 2024
 
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdfGUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
 

PROBLEMAS DE PROGRAMACION 3

  • 1. Soluciones de la dirigida 5 #include<stdio.h> int inicio(void); // Prototipo de la funcin universo int muestra(int n); // Prototipo de la funcin muestra int combinatoria(int n, int k); // Prototipo de la funcin combinatoria int main() { int n,k; n = inicio(); k = muestra(n); printf("El n'umero de combinaciones de %d elemento(s) de %d elemento(s) dado(s) es %dn",k,n,combinatoria(n,k)); } int inicio(void) // cabecera de la definicin universo { int ok = 0; int n; // variable donde almacenar'e lo que voy a retornar printf("Ingrese un entero positivo: "); scanf("%d",&n); return n; } int muestra(int n) // cabecera de la definicin de la funci'on muestra { int ok = 0; int k; // variable donde almacenar'e lo que voy a retornar printf("Ingrese un entero positivo menor o igual a %d: ",n); scanf("%d",&k); return k; } int combinatoria(int n, int k) // cabecera de la definicin de la funcin combinatoria { if (k == 1) return n; else if (n == k) return 1; else return combinatoria(n-1,k-1) + combinatoria(n-1,k); } #include<stdio.h> int ingresar(void); // Prototipo de la funcin ingresar int fibo(int n); // Prototipo de la funcin fibo void main() { int n; n = ingresar(); printf(" F(%d) = %d.nn", n, fibo(n)); } int ingresar(void) // cabecera de la definicin de la funci'on exponente { int n; // variable donde almacenar'e lo que voy a retornar printf("n Ingrese el exponente (n'umero entero): "); scanf("%d",&n); return n; } int fibo(int n) // cabecera de la definicin de la funcin fibo { if ( n <= 2 ) return 1; // fibo(1) = fibo (2) = 1 else return fibo(n-1) + fibo(n-2); // fibo(n) = fibo(n-1) + fibo(n-2) } #include<stdio.h>
  • 2. float base(void); // Prototipo de la funcin base int exponente(void); // Prototipo de la funcin exponente float potencia(float b, int n); // Prototipo de la funcin potencia int main() { float b; int n; b = base(); n = exponente(); printf("%f elevado a la %d es igual a %fn",b,n,potencia(b,n)); } float base(void) // cabecera de la definicin base { int ok = 0; float b; // variable donde almacenar'e lo que voy a retornar printf("Ingrese la base (n'umero positivo): "); scanf("%f",&b); return b; } int exponente(void) // cabecera de la definicin de la funci'on exponente { int n; // variable donde almacenar'e lo que voy a retornar printf("Ingrese el exponente (n'umero entero): "); scanf("%d",&n); return n; } float potencia(float b, int n) // cabecera de la definicin de la funcin potencia { float retorno = 1; if ( n > 0 ) retorno = b*potencia(b,n-1); if ( n < 0 ) retorno = potencia(b,n+1)/b; return retorno; } /* * Un programa en C para encontrar el MCD de dos numeros usando recursion */ #include <stdio.h> int gcd(int, int); int main() { int a, b, resultado; printf(" Ingresa dos numeros para encontrar el MCD:"); scanf("%d%d", &a, &b); resultado = mcd(a, b); printf("El MCD DE %d y %d es %d.n", a, b, resultado); } int mcd(int a, int b) { while (a != b) { if (a > b) { return mcd(a - b, b); } else { return mcd(a, b - a); } } return a; }
  • 3. /* * Un programa para revertir un numero */ #include <stdio.h> #include <math.h> int rev(int, int); int main() { int num, resultado; int longitud = 0, temp; printf("Ingresar un numero entero para revertir: "); scanf("%d", &num); temp = num; while (temp != 0) { longitud++; temp = temp / 10; } resultado = rev(num, longitud); printf("El reverso de %d es %d.n", num, resultado); return 0; } int rev(int num, int len) { if (len == 1) { return num; } else { return (((num % 10) * pow(10, len - 1)) + rev(num / 10, --len)); } }