C Program To Compute Power

C Program :

/* Aim: Write a program to accept two integers x and n and compute x raise to n */ 

#include<stdio.h>
void main()
{  
	int i=1,x,n,prod=1;
 
	printf("\n Enter any number and power:- ");
	scanf("%d%d",&x,&n);
 
	do
	{
	prod=prod*x;
	i++;
	}while(i<=n);   
	printf("\n The value of %d^%d is %d \n \n",x,n,prod);

} // End of code


/* Output of above code:

[root@localhost ~]# gcc -o e4a3 e4a3.c
[root@localhost ~]# ./e4a3

 Enter any number and power:- 4 2

 The value of 4^2 is 16 

*/ 

Comments