In this tutorial, we are going to write a C Program to evaluate the equation y=xn when n is a non-negative integer in C Programming with practical program code and step-by-step full complete explanation.

c program to evaluate the equation y=xn when n is a non negative integer


C Program to evaluate the equation y=xn

 
#include<stdio.h>
#include<conio.h>

void main()
{
    int count, n;
    float x,y;

    printf("Enter the values of x and n: ");
    scanf("%f%d",&x,&n);

    y=1.0;
    count=1;

    while(count<=n)
    {
        y=y*x;
        count++;
    }

    printf("x=%f n=%d x to power n=%f",x,n,y);
}


Output

 
Enter the values of x and n: 2.5 4
X=x.500000 n=4 x to power n=39.062500