Program to find the value of x^{n}
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int x, n, count = 1, sum = 1;
clrscr();
printf("Enter the value of x : ");
scanf("%d", &x);
printf("\nEnter the value of n : ");
scanf("%d", &n);
while(count <= n)
{
sum = sum * x;
count++;
}
printf("\nThe power of %d^%d is : %d", x, n, sum);
getch();
}
Output:
Enter the value of x : 2
Enter the value of n : 4
The power of 2^4 is : 16

CreatedOct 15, 2014

UpdatedDec 30, 2019

Views3,771
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order