Chapter - 4: The Loop Control Structure

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.


B
Sections
3
Exercises
#include<stdio.h>
#include<conio.h>
int main()
{
	int base, power, ans = 1;
	printf("\nEnter two numbers : ");
	scanf("%d%d", &base, &power);
	
	if(power == 0);
	else
		while(power)
		{
			ans *= base;
			power--;
		}
	
	printf("\nAnswer = %d", ans);
	
	getch();
	return 0;
}

© 2021 Garbage Valuegarbage value logo