C语言题目:任意输入两个数,输出其商。注意如果除数不为0则输出其商,如果除数为0则输出“no”。怎么做

2025-03-10 05:36:59
推荐回答(2个)
回答1:

#include
int main()
{float a,b,c;
scanf("%f,%f",&a,&b);
if (b==0)
{
printf("no\n");
}
else
{
c = a/b;
printf("%f",c);
}
return 0;
}

回答2:

#include

void main(){
float a,b;
printf("a b=?");
scanf("%f%f",&a,&b);
if(b!=0)
printf("%.2f\n", a/b);
else
printf("no\n");
}