Skip to content

Instantly share code, notes, and snippets.

@jmramirezpro
Created February 26, 2016 12:50
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 jmramirezpro/b02dad384a366d2dabd8 to your computer and use it in GitHub Desktop.
Save jmramirezpro/b02dad384a366d2dabd8 to your computer and use it in GitHub Desktop.
/*
* Exponente.c
* Ejercicios del Podcast Codigo Fuente - Programa 023
* Escribe un programa en C que lea dos números: a de tipo float y b de tipo int.
* El programa debe calcular a elevado a b.
* Creado el 24 de feb. de 2016
* Author: jmramirez
*/
#include <stdio.h>
int main(void)
{
float a;
int b;
float potencia = 1;
int j;
printf("Introduce el valor de a: ");
if (scanf("%f", &a) < 1){
printf("Error de la lectura de a\n");
return (0);
}
printf("Introduce el valor de b: ");
if (scanf("%d", &b) < 1){
printf("Error de la lectura de b\n");
return (0);
}
for (j = 0; j < b; j++){
potencia = potencia * a;
}
printf("%f elevado a %d = %f\n", a, b, potencia);
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment