C Program to Find Power of a number using for Loop

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

	int main()
		int a, b;
		long  pnum = 1;
		printf("Enter the value of A :");
		printf("Enter the value of B :");
		if (b > 0)
			for (int i = b; i>0; i--)
				pnum = pnum * a;
		else if(b =0){
		printf("%d Raised to the Power of %d is %d",a,b ,pnum);


	Enter the value of A :7
	Enter the value of B :2
	7 Raised to the Power of 2 is 49

Compile and Run Online

Subscribe For Daily Updates