/*--------------------------------------------------------------------*/ /* powerunsigned.c */ /* Author: Bob Dondero */ /*--------------------------------------------------------------------*/ #include /*--------------------------------------------------------------------*/ static unsigned int uiBase; /* Bad style. */ static unsigned int uiExp; /* Bad style. */ static unsigned int uiPower = 1; /* Bad style. */ static unsigned int uiIndex; /* Bad style. */ /*--------------------------------------------------------------------*/ /* Read a non-negative base and exponent from stdin. Write base raised to the exponent power to stdout. Return 0. */ int main(void) { printf("Enter the base: "); scanf("%u", &uiBase); /* Should validate. */ printf("Enter the exponent: "); scanf("%u", &uiExp); /* Should validate. */ for (uiIndex = 1; uiIndex <= uiExp; uiIndex++) uiPower *= uiBase; printf("%u to the %u power is %u.\n", uiBase, uiExp, uiPower); return 0; }