So I tried write a code to convert kmph to m/s And wanted to validate using Assert.
Here is the piece of code I wrote. The value is correct when tried comparing with print statements but assert gives an error
#include <stdio.h>
#include <assert.h>
float convert(float num);
int main()
{
float kmph;
printf("Enter Velocity in Kmph\n");
scanf("%f", &kmph);
printf("Velocity in m/s is %f\n", convert(kmph));
assert(convert(1) == 0.277778);
assert(convert(18) == 5.0);
return 0;
}
float convert(float num)
{
float mps;
mps = num * 0.277778;
return mps;
}
error description:
Enter Velocity in Kmph
1
Velocity in m/s is 0.277778
a.out: program4.c:14: main: Assertion `convert(1) == 0.277778' failed.
Aborted (core dumped)