Created
February 26, 2016 12:50
-
-
Save jmramirezpro/b02dad384a366d2dabd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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