C语言求e^x次方,for循环

求e^x次方,for循环
。。。。。。。。。。。。。。。。。。。。。。。


#include <stdio.h>

int main()
{
    const float e = 2.71;
    float y=1;
    int x;
    scanf("%d",&x);
    if(x==0)
    y=1.0;
    if(x<0)
    for(int i=1;i<=-x;i++)
    {
        y=y/e;
    }
    if(x>0)
    for(int i=1;i<=x;i++)
    {
        y=y*e;
    }
    printf("e^x=%f",y);
    
}

https://blog.csdn.net/hua12ng/article/details/103257314?utm_source=app&app_version=4.18.0