用C语言或者C++编程

有如下函数,编写程序输入x的值,输出y的值。 x (x<0)
y= x^2 (0≤x≤10)
3x-11 (x>10)

#include <stdio.h>
int main() {
    double x,y;
    scanf("%lf",&x);
    if(x>=0&&x<=10){
        y=x*x;
    }else if(x>10){
        y=3*x-11;
    }
    printf("%lf",y);
    return 0;
}

觉得有用的话采纳一下哈