lundi 28 septembre 2020

ASSERT in CPROGRAM [duplicate]

In C program when I use float value in assert then it doesn't accept my value. Is there any Solution??????

Code:

int main(){

//first value passed
float  n1=5.0, a[]={10.0,20.0,30.0,40.0,50.0};
float m1,sd1;
m1= ceilf(mean(a,n1)*100)/100;
sd1= ceilf(sd(a,n1,m1)*100)/100;
assert(m1==30.0 && sd1==14.150 );
printf("\nmean=%2f \nSD=%2f",m1,sd1);

//secound value passed
float b[]={10.0,11.0,12.0,13.0,14.0,16.0,17.0},n2=7.0,m2,sd2;
m2= ceilf(mean(b,n2)*100)/100;
sd2= ceilf(sd(b,n2,m2)*100)/100;
assert(m2==13.2900 && sd2==2.3800);
printf("\nmean=%f \nSD=%f",m2,sd2);
return 0;

}

Aucun commentaire:

Enregistrer un commentaire