generate functionSat, 06 May 2023

write a program that receives the base and the exponent from the user and calculates the potency

#include <stdio.h> int main(void) { int base, exponent; int result = 1; printf("Enter the base: "); scanf("%d", &base); printf("Enter the exponent: "); scanf("%d", &exponent); // Calculate the result while(exponent != 0) { result *= base; --exponent; } printf("The result is %d\n", result); return 0; }

Questions about programming?Chat with your personal AI assistant