30/09/2018, 21:42
Em muốn hỏi một chút về c ạ. mong mn giúp đỡ
ở bài này em viết xong chương trình rồi chạy đc rồi nhưng khi nhập a=b=0 thì đáp án không ra bằng 0 em ko hiểu code bị nhầm ở đâu mn giúp em với ạ.
đây là code của em ạ:
#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(int a, int b, float x)
{
float s;
if(a+b!=0)
{
s=exp(x)/(a+b);
}
else if(a==b==0)
{
s=0;
}
else
{
s=(pow(a,2)+pow(b,2)+100)+sin(x)*sin(x)*sin(x);
}
return s;
}
int nhap()
{
float temp;
printf("
moi ban nhap :");
scanf("%f",&temp);
return temp;
}
int main()
{
float s;
int a;
int b;
float x;
a=nhap();
b=nhap();
x=nhap();
s=f(a,b,x);
printf("
ket qua la: %.2f", s);
return 0;
}
Bài liên quan
em cảm ơn nhiều ạ